James//@version=5
indicator("Forex Entry Signals (RSI + EMA)", overlay=false)
// Configuração do RSI
rsiLength = input(14, "RSI Length")
rsi = ta.rsi(close, rsiLength)
// Configuração da EMA
emaLength = input(50, "EMA Length")
ema = ta.ema(close, emaLength)
// Lógica de compra e venda
buySignal = ta.crossover(close, ema) and rsi < 30
sellSignal = ta.crossunder(close, ema) and rsi > 70
// Plot do RSI
plot(rsi, color=color.blue, linewidth=2, title="RSI")
hline(70, "Overbought", color=color.red)
hline(30, "Oversold", color=color.green)
// Marcar setas no gráfico
if buySignal
label.new(bar_index, close, text="BUY", color=color.green, style=label.style_label_up, textcolor=color.white, size=size.small)
if sellSignal
label.new(bar_index, close, text="SELL", color=color.red, style=label.style_label_down, textcolor=color.white, size=size.small)
Индикаторы и стратегии
Fake Double ReserveThis Pine Script code implements the "Fake Double Reserve" indicator, combining several widely-used technical indicators to generate Buy and Sell signals. Here's a detailed breakdown:
Key Indicators Included
Relative Strength Index (RSI):
Used to measure the speed and change of price movements.
Overbought and oversold levels are set at 70 and 30, respectively.
MACD (Moving Average Convergence Divergence):
Compares short-term and long-term momentum with a signal line for trend confirmation.
Stochastic Oscillator:
Measures the relative position of the closing price within a recent high-low range.
Exponential Moving Averages (EMAs):
EMA 20: Short-term trend indicator.
EMA 50 & EMA 200: Medium and long-term trend indicators.
Bollinger Bands:
Shows volatility and potential reversal zones with upper, lower, and basis lines.
Signal Generation
Buy Condition:
RSI crosses above 30 (leaving oversold territory).
MACD Line crosses above the Signal Line.
Stochastic %K crosses above %D.
The closing price is above the EMA 50.
Sell Condition:
RSI crosses below 70 (leaving overbought territory).
MACD Line crosses below the Signal Line.
Stochastic %K crosses below %D.
The closing price is below the EMA 50.
Visualization
Signals:
Buy signals: Shown as green upward arrows below bars.
Sell signals: Shown as red downward arrows above bars.
Indicators on the Chart:
RSI Levels: Horizontal dotted lines at 70 (overbought) and 30 (oversold).
EMAs: EMA 20 (green), EMA 50 (blue), EMA 200 (orange).
Bollinger Bands: Upper (purple), Lower (purple), Basis (gray).
Labels:
Buy and Sell signals are also displayed as labels at relevant bars.
//@version=5
indicator("Fake Double Reserve", overlay=true)
// Include key indicators
rsiLength = 14
rsi = ta.rsi(close, rsiLength)
macdFast = 12
macdSlow = 26
macdSignal = 9
= ta.macd(close, macdFast, macdSlow, macdSignal)
stochK = ta.stoch(close, high, low, 14)
stochD = ta.sma(stochK, 3)
ema20 = ta.ema(close, 20)
ema50 = ta.ema(close, 50)
ema200 = ta.ema(close, 200)
bbBasis = ta.sma(close, 20)
bbUpper = bbBasis + 2 * ta.stdev(close, 20)
bbLower = bbBasis - 2 * ta.stdev(close, 20)
// Detect potential "Fake Double Reserve" patterns
longCondition = ta.crossover(rsi, 30) and ta.crossover(macdLine, signalLine) and ta.crossover(stochK, stochD) and close > ema50
shortCondition = ta.crossunder(rsi, 70) and ta.crossunder(macdLine, signalLine) and ta.crossunder(stochK, stochD) and close < ema50
// Plot signals
if (longCondition)
label.new(bar_index, high, "Buy", style=label.style_label_up, color=color.green, textcolor=color.white)
if (shortCondition)
label.new(bar_index, low, "Sell", style=label.style_label_down, color=color.red, textcolor=color.white)
// Plot buy and sell signals as shapes
plotshape(longCondition, style=shape.labelup, location=location.belowbar, color=color.green, size=size.small, title="Buy Signal")
plotshape(shortCondition, style=shape.labeldown, location=location.abovebar, color=color.red, size=size.small, title="Sell Signal")
// Plot indicators
plot(ema20, color=color.green, linewidth=1, title="EMA 20")
plot(ema50, color=color.blue, linewidth=1, title="EMA 50")
plot(ema200, color=color.orange, linewidth=1, title="EMA 200")
hline(70, "Overbought (RSI)", color=color.red, linestyle=hline.style_dotted)
hline(30, "Oversold (RSI)", color=color.green, linestyle=hline.style_dotted)
plot(bbUpper, color=color.purple, title="Bollinger Band Upper")
plot(bbLower, color=color.purple, title="Bollinger Band Lower")
plot(bbBasis, color=color.gray, title="Bollinger Band Basis")
Implied and Historical VolatilityAbstract
This TradingView indicator visualizes implied volatility (IV) derived from the VIX index and historical volatility (HV) computed from past price data of the S&P 500 (or any selected asset). It enables users to compare market participants' forward-looking volatility expectations (via VIX) with realized past volatility (via historical returns). Such comparisons are pivotal in identifying risk sentiment, volatility regimes, and potential mispricing in derivatives.
Functionality
Implied Volatility (IV):
The implied volatility is extracted from the VIX index, often referred to as the "fear gauge." The VIX represents the market's expectation of 30-day forward volatility, derived from options pricing on the S&P 500. Higher values of VIX indicate increased uncertainty and risk aversion (Whaley, 2000).
Historical Volatility (HV):
The historical volatility is calculated using the standard deviation of logarithmic returns over a user-defined period (default: 20 trading days). The result is annualized using a scaling factor (default: 252 trading days). Historical volatility represents the asset's past price fluctuation intensity, often used as a benchmark for realized risk (Hull, 2018).
Dynamic Background Visualization:
A dynamic background is used to highlight the relationship between IV and HV:
Yellow background: Implied volatility exceeds historical volatility, signaling elevated market expectations relative to past realized risk.
Blue background: Historical volatility exceeds implied volatility, suggesting the market might be underestimating future uncertainty.
Use Cases
Options Pricing and Trading:
The disparity between IV and HV provides insights into whether options are over- or underpriced. For example, when IV is significantly higher than HV, options traders might consider selling volatility-based derivatives to capitalize on elevated premiums (Natenberg, 1994).
Market Sentiment Analysis:
Implied volatility is often used as a proxy for market sentiment. Comparing IV to HV can help identify whether the market is overly optimistic or pessimistic about future risks.
Risk Management:
Institutional and retail investors alike use volatility measures to adjust portfolio risk exposure. Periods of high implied or historical volatility might necessitate rebalancing strategies to mitigate potential drawdowns (Campbell et al., 2001).
Volatility Trading Strategies:
Traders employing volatility arbitrage can benefit from understanding the IV/HV relationship. Strategies such as "long gamma" positions (buying options when IV < HV) or "short gamma" (selling options when IV > HV) are directly informed by these metrics.
Scientific Basis
The indicator leverages established financial principles:
Implied Volatility: Derived from the Black-Scholes-Merton model, implied volatility reflects the market's aggregate expectation of future price fluctuations (Black & Scholes, 1973).
Historical Volatility: Computed as the realized standard deviation of asset returns, historical volatility measures the intensity of past price movements, forming the basis for risk quantification (Jorion, 2007).
Behavioral Implications: IV often deviates from HV due to behavioral biases such as risk aversion and herding, creating opportunities for arbitrage (Baker & Wurgler, 2007).
Practical Considerations
Input Flexibility: Users can modify the length of the HV calculation and the annualization factor to suit specific markets or instruments.
Market Selection: The default ticker for implied volatility is the VIX (CBOE:VIX), but other volatility indices can be substituted for assets outside the S&P 500.
Data Frequency: This indicator is most effective on daily charts, as VIX data typically updates at a daily frequency.
Limitations
Implied volatility reflects the market's consensus but does not guarantee future accuracy, as it is subject to rapid adjustments based on news or events.
Historical volatility assumes a stationary distribution of returns, which might not hold during structural breaks or crises (Engle, 1982).
References
Black, F., & Scholes, M. (1973). "The Pricing of Options and Corporate Liabilities." Journal of Political Economy, 81(3), 637-654.
Whaley, R. E. (2000). "The Investor Fear Gauge." The Journal of Portfolio Management, 26(3), 12-17.
Hull, J. C. (2018). Options, Futures, and Other Derivatives. Pearson Education.
Natenberg, S. (1994). Option Volatility and Pricing: Advanced Trading Strategies and Techniques. McGraw-Hill.
Campbell, J. Y., Lo, A. W., & MacKinlay, A. C. (2001). The Econometrics of Financial Markets. Princeton University Press.
Jorion, P. (2007). Value at Risk: The New Benchmark for Managing Financial Risk. McGraw-Hill.
Baker, M., & Wurgler, J. (2007). "Investor Sentiment in the Stock Market." Journal of Economic Perspectives, 21(2), 129-151.
Transparent Ichimoku CloudTransparent Ichimoku Cloud
The Transparent Ichimoku Cloud is a modified version of the traditional Ichimoku indicator, designed to reduce visual clutter on your charts. While the original Ichimoku Cloud is highly informative, its bold colors and dense visuals can sometimes make it difficult to focus on other elements of the chart. This version addresses that issue by making the lines and the cloud more transparent, providing a cleaner, less overwhelming experience for traders.
Why Use This Indicator?
Reduced Visual Noise:
By lowering the opacity of the lines and the cloud, this version ensures the Ichimoku analysis doesn't overpower your chart. This is particularly useful for traders who prefer a minimalistic view or work with multiple indicators simultaneously.
Retains Ichimoku's Core Functionality:
All essential components of the Ichimoku system—Conversion Line, Base Line, Lagging Span, and the Cloud (Kumo)—are still present, but with a visually subtle appearance.
Customization Options:
Fully customizable inputs for the lengths of the Conversion Line, Base Line, Leading Span B, and the displacement period, allowing you to adapt the indicator to your trading style.
How It Works:
Conversion Line (Tenkan-Sen):
Displays the midpoint of the highest high and lowest low over a short period (default: 9 bars).
Base Line (Kijun-Sen):
Displays the midpoint of the highest high and lowest low over a longer period (default: 26 bars).
Leading Spans (Senkou Span A/B):
Span A: The average of the Conversion Line and Base Line, projected forward.
Span B: The midpoint of the highest high and lowest low over an extended period (default: 52 bars), also projected forward.
Lagging Span (Chikou Span):
The current close price, plotted backward by the displacement period (default: 26 bars).
Kumo Cloud:
The area between Leading Span A and B, filled with transparent colors to indicate bullish or bearish trends.
Why Transparency Matters:
The Ichimoku Cloud is one of the most powerful tools for identifying trends, momentum, and support/resistance levels. However, the default visuals can be overwhelming, especially on a busy chart. By making the lines 20% transparent and the cloud 10% transparent, this version balances clarity with functionality, giving you all the information you need without the distraction.
Usage Tips:
Combine this indicator with candlestick analysis, support/resistance levels, or other trend indicators for enhanced decision-making.
Experiment with different input lengths to tailor the indicator to your trading timeframe and asset type.
Use the subtle visuals to overlay Ichimoku on charts with other indicators without overcrowding your view.
Conclusion:
The Transparent Ichimoku Cloud offers the same depth of analysis as the traditional Ichimoku system, but with a cleaner, more modern appearance. If you've ever found the default Ichimoku indicator too visually intense, this version is for you. Simplify your charts without sacrificing insight—try it today!
Outside Bar Strategy % (Alessio)Outside Bar Strategy %
This strategy is based on identifying Outside Bars, which occur when the current bar's high is higher than the previous bar's high and its low is lower than the previous bar's low. The strategy enters trades in the direction of the Outside Bar, offering a powerful way to capture price moves following a strong price expansion.
Key Features:
Long and Short Entries: The strategy enters a Long trade when the Outside Bar closes bullish (current close > open), and a Short trade when the Outside Bar closes bearish (current close < open).
Customizable Entry Levels: The entry point is calculated based on a customizable percentage of the Outside Bar's range, allowing flexibility for traders to fine-tune their entries at 50% or 70% of the bar's range.
Stop Loss (SL) and Take Profit (TP):
Stop Loss (SL) is automatically placed at the Outside Bar's low for Long trades and at its high for Short trades.
Take Profit (TP) is calculated as a percentage of the Outside Bar's range, with customizable settings for take-profit levels.
Visual Indicators:
Entry, Stop Loss, and Take Profit levels are plotted as lines on the chart, with customizable colors and widths for easy identification.
Labels are placed on the chart to indicate whether the trade is Long or Short, positioned above or below the Outside Bar's candlestick.
Alerts: Users can enable alerts to receive notifications when a trade is triggered, including details such as entry points and stop loss levels.
Strategy Parameters:
Entry Percentage: Set the entry level as a percentage of the Outside Bar's range (e.g., 50%, 70%).
Take Profit Percentage: Customize the Take Profit level as a percentage of the Outside Bar's range.
Customizable Colors and Line Widths: Adjust the colors and thickness of the entry, stop loss, and take profit lines to fit your preferences.
Alerts: Enable alerts to be notified when a trade is executed or when the entry level is reached.
This strategy is ideal for traders who want to capitalize on significant price moves after a breakout, with clear risk management through Stop Loss and Take Profit levels. The customizable features make it suitable for various market conditions and trading styles.
RSI ve EMA Tabanlı Alım-Satım StratejisiBu strateji, kısa vadeli ticaret yaparken güçlü trendleri takip etmeye ve riskleri en aza indirgemeye odaklanır. Strateji, aşağıdaki göstergelere dayanarak alım ve satım sinyalleri üretir:
Alım Sinyali:
EMA 50 değeri, EMA 200'ün üzerinde olmalı, yani trend yukarı yönlü olmalı.
MACD göstergesi sıfırın altında olmalı ve önceki değeri aşarak yükselmiş olmalı. Bu, güçlenen bir düşüş trendinden çıkıp yükselişe geçişi işaret eder.
Satım Sinyali:
RSI 14 göstergesi 70 seviyesini yukarıdan aşağıya kırarsa, aşırı alım durumunun sona erdiği ve fiyatın geri çekilebileceği sinyali verilir.
Stop Loss:
Eğer EMA 50 değeri, EMA 200'ün altına düşerse, strateji mevcut pozisyonu kapatarak zararı sınırlamayı hedefler.
Bu strateji, trend takibi yapan ve risk yönetimine önem veren yatırımcılar için tasarlanmıştır. Hem alım hem de satım koşulları, piyasa koşullarını dinamik bir şekilde analiz eder ve sadece trend yönündeki hareketlere odaklanır. RSI, MACD ve EMA göstergeleriyle desteklenen alım-satım sinyalleri, güçlü ve güvenilir bir ticaret stratejisi oluşturur.
Ekstra Notlar:
Strateji, trend yönünde işlem yaparak daha sağlam pozisyonlar almanızı sağlar.
Stop loss seviyeleri, güçlü trend dönüşleri durumunda korunmaya yardımcı olur.
Bu strateji özellikle yükseliş trendleri sırasında alım yapmayı tercih eder ve aşırı alım koşullarında satışı gerçekleştirir.
G8LD N8V8L Flower Approximation and SetupBasically when you see the indicator telling you to get out of the trade you should get out
Bollinger Bands+ VWAP+Super trend by Prashant MohiteBollinger Bands 3 types plus VWAP plus 2 super trends Super trend
VWAP and 9 EMA Multi-Timeframe Strategyvwap and 9 ema confluence plus pullback opportunities. using this on 4hr for trend and 15 minute for entries could have favorable results.
Enhanced VIP-like IndicatorSettings Breakdown Tutorial: Optimizing a Trading Strategy
This guide explains the key trading strategy settings and how to customize them based on your trading style and goals. Each parameter is essential for tailoring the strategy to market conditions and your risk appetite.
1. Short Moving Average Length (Default: 9)
• Purpose: Tracks short-term trends using a small number of candles.
• Settings Tips:
• Smaller Values (e.g., 9): Quickly react to price changes, useful for fast-moving markets.
• Larger Values (e.g., 12-15): Generate smoother signals for less volatile trades.
2. Long Moving Average Length (Default: 21)
• Purpose: Identifies long-term trends.
• Settings Tips:
• Higher Values (e.g., 50): Spot broader trends at the expense of slower signals.
• Trend Analysis: The interaction of short and long MAs helps determine bullish or bearish trends (e.g., bullish when short MA crosses above long MA).
3. Higher Timeframe MA Length (Default: 200)
• Purpose: Filters long-term trends on a higher timeframe (e.g., daily).
• Settings Tips:
• 200 Periods: Standard for defining bullish (price above) or bearish (price below) markets.
• Adjustable: Use 100 for faster responses or stick with 200 for reliability.
4. Higher Timeframe (Default: 1 Day)
• Purpose: Defines the timeframe for the higher moving average.
• Settings Tips:
• Shorter Timeframes (e.g., 4 Hours): More frequent trading signals.
• Daily Timeframe: Best for swing trading and identifying macro trends.
5. RSI Length (Default: 14)
• Purpose: Measures momentum over a specific number of candles.
• Settings Tips:
• Lower Values (e.g., 7): More sensitive to price changes, ideal for quick trades.
• Higher Values (e.g., 20): Smooth signals for more stable markets.
6. RSI Overbought (70) and Oversold (30) Levels
• Purpose: Marks thresholds for overbought and oversold conditions.
• Settings Tips:
• Stricter Levels (e.g., 80/20): Fewer, higher-quality signals.
• Looser Levels (e.g., 65/35): More frequent signals, suitable for active trading.
7. Pivot Left Bars (5) and Pivot Right Bars (5)
• Purpose: Confirms pivot points (support/resistance) based on surrounding candles.
• Settings Tips:
• Higher Values (e.g., 10): Stronger but less frequent pivot points.
• Lower Values: More responsive, for traders seeking quick pivots.
8. Take Profit Percentage (Default: 2%)
• Purpose: Defines the profit level to exit trades.
• Settings Tips:
• Higher Values (e.g., 5%): For swing traders holding positions longer.
• Lower Values (e.g., 1%): For scalpers focusing on quick trades.
9. Minimum Volume (Default: 1,000,000)
• Purpose: Ensures sufficient liquidity for trading.
• Settings Tips:
• Lower Values: For lower-volume markets.
• Higher Values: Reduces risk in high-liquidity assets.
10. Stop Loss Percentage (Default: 1%)
• Purpose: Sets the maximum acceptable loss per trade.
• Settings Tips:
• Lower Values (e.g., 0.5%): Reduces risk, suited for conservative trading.
• Higher Values (e.g., 2%): Allows more price fluctuation, ideal for volatile markets.
11. Entry Conditions
• Options:
• MA Crossover & RSI: Combines trend-following and momentum for well-rounded signals.
• Pivot Breakout: Focuses on support/resistance breakouts for high-impact trades.
• Settings Tips:
• Trend-Following Traders: Use MA Crossover & RSI.
12. Exit Conditions
• Options:
• Opposite Signal: Exits when the trade’s opposite condition occurs (e.g., bullish to bearish).
• Fixed Take Profit/Stop Loss: Exits based on predefined profit/loss thresholds.
• Settings Tips:
• Opposite Signal: Ideal for trend-following strategies.
Summary
Customizing these settings aligns the strategy with your trading goals. Test configurations in a demo environment before live trading to refine the approach and optimize results. Always balance profit potential with risk management.
• Fixed Levels: Better for strict risk management.
• Breakout Traders: Opt for Pivot Breakout.
GTİThis indicator is designed to detect gaps between candles on the chart. It detects all gaps that are higher than the specified percentage setting, draws a line passing through only the starting and ending points of the last gap, and paints between these lines.
If any candle closes above the gap starting level, the lines between the lines are colored green; If any candle closes below the gap starting level, the lines between the lines are colored red.
10-Day EMA with 2-Hour Trend Filter - Taylor WelchDirectional on the 2 hour, entry point on the 3 minute.
20-34 Dual Dot Alerts OnlyPine Script that uses dual Donchian Channels (20-period and 34-period) and places tiny blue dots above candles when the highest price touches any upper Donchian Channel and below candles when the lowest price touches any lower Donchian Channel, without displaying the channels themselves, you can use the code.
### Explanation of the Code:
1. **Indicator Declaration**: The script is named "Dual Donchian Channels Dots Only" and overlays on the price chart.
2. **Input for Lengths**: Users can set lengths for two Donchian Channels (20 and 34 periods).
3. **Calculating Bands**: The upper and lower bands are calculated using `ta.highest` and `ta.lowest` functions over the specified periods.
4. **Touch Conditions**:
- `upperTouch`: Checks if the highest price of the current candle touches either of the upper bands.
- `lowerTouch`: Checks if the lowest price of the current candle touches either of the lower bands.
5. **Plotting Dots**:
- A tiny blue dot is plotted above bars where `upperTouch` is true.
- A tiny blue dot is plotted below bars where `lowerTouch` is true.
### How to Use:
1. Copy this script into TradingView’s Pine Script editor.
2. Save it and add it to your chart.
3. You will see tiny blue dots appear above or below candles based on whether they touch any of the upper or lower Donchian Bands.
This setup provides a clear visual indication of price interactions with both Donchian Channels while keeping the chart uncluttered by hiding the channel lines.
Vlad MTF Clouds MultiColorAll Credit to Ripster.
This is a copy of his MTF Cloud but I've added the bullish/bearish color coding ability.
ema 59 Giải thích mã:
Thêm biến buyLabel và sellLabel:
buyLabel và sellLabel được sử dụng để xác định khi nào label Buy hoặc Sell xuất hiện trên biểu đồ.
Cảnh báo khi label Buy xuất hiện:
Sử dụng alertcondition với điều kiện outsideBarCrossAbove để thông báo khi label Buy xuất hiện.
Cảnh báo khi label Sell xuất hiện:
Sử dụng alertcondition với điều kiện outsideBarCrossBelow để thông báo khi label Sell xuất hiện.
Thông báo chi tiết:
Thông báo sẽ hiển thị giá tại thời điểm label xuất hiện.
Ví dụ thông báo:
Khi label Buy xuất hiện: "Label Buy xuất hiện tại giá: 1.1050".
Khi label Sell xuất hiện: "Label Sell xuất hiện tại giá: 1.1000".
Lưu ý:
Đảm bảo rằng bạn đã bật cảnh báo trong TradingView để nhận thông báo khi label xuất hiện.
Kiểm tra kỹ lưỡng chiến lược trên dữ liệu lịch sử trước khi sử dụng trong giao dịch thực tế.
Nếu bạn muốn thông báo chi tiết hơn (ví dụ: thêm thông tin về số lượng hợp đồng hoặc vị thế), bạn có thể sử dụng alert trong strategy thay vì alertcondition. Tuy nhiên, alert chỉ hoạt động với strategy, không hoạt động với indicator.
image.png
PNG 11.25KB
Lỗi "Void expression cannot be assigned to a variable" xảy ra khi bạn cố gắng gán một biểu thức không trả về giá trị (void) vào một biến. Trong Pine Script, hàm plotshape không trả về giá trị nào, vì vậy bạn không thể gán nó vào một biến như buyLabel hoặc sellLabel.
Nguyên nhân:
Bạn đang cố gắng gán kết quả của plotshape vào biến buyLabel và sellLabel, nhưng plotshape không trả về giá trị.
Cách sửa lỗi:
Bạn không cần gán plotshape vào biến. Thay vào đó, bạn có thể sử dụng trực tiếp điều kiện outsideBarCrossAbove và outsideBarCrossBelow để tạo cảnh báo.
Dưới đây là đoạn mã đã được sửa:
pinescript
Copy
//@version=5
strategy(title="Outside Bar EMA Crossover Strategy with EMA Shift", shorttitle="Outside Bar EMA Cross", overlay=true)
// Input for EMA lengths
lenEMA1 = input.int(5, title="EMA 5 Length")
lenEMA2 = input.int(9, title="EMA 9 Length")
// Input for EMA 9 shift
emaShift = input.int(1, title="EMA 9 Shift", minval=0)
// Calculate EMAs
ema1 = ta.ema(close, lenEMA1)
ema2 = ta.ema(close, lenEMA2)
// Apply shift to EMA 9
ema2Shifted = na(ema2 ) ? na : ema2 // Dịch chuyển EMA 9 bằng cách sử dụng offset
// Plot EMAs
plot(ema1, title="EMA 5", color=color.blue, linewidth=2)
plot(ema2Shifted, title="EMA 9 Shifted", color=color.red, linewidth=2)
// Outside Bar condition
outsideBar() => high > high and low < low
// Cross above EMA 5 and EMA 9 (shifted)
crossAboveEMA = close > ema1 and close > ema2Shifted
// Cross below EMA 5 and EMA 9 (shifted)
crossBelowEMA = close < ema1 and close < ema2Shifted
// Outside Bar cross above EMA 5 and EMA 9 (shifted)
outsideBarCrossAbove = outsideBar() and crossAboveEMA
// Outside Bar cross below EMA 5 and EMA 9 (shifted)
outsideBarCrossBelow = outsideBar() and crossBelowEMA
// Plot shapes for visual signals
plotshape(series=outsideBarCrossAbove, title="Outside Bar Cross Above", location=location.belowbar, color=color.green, style=shape.labelup, text="Buy", textcolor=color.white)
plotshape(series=outsideBarCrossBelow, title="Outside Bar Cross Below", location=location.abovebar, color=color.red, style=shape.labeldown, text="Sell", textcolor=color.white)
// Calculate Outside Bar height
outsideBarHeight = high - low // Chiều cao của nến Outside Bar
// Calculate TP and SL levels
tpRatio = 0.5 // TP = 50% chiều cao nến Outside Bar
slRatio = 1.0 // SL = 100% chiều cao nến Outside Bar
tpLevelLong = close + outsideBarHeight * tpRatio // TP cho lệnh mua
slLevelLong = close - outsideBarHeight * slRatio // SL cho lệnh mua
tpLevelShort = close - outsideBarHeight * tpRatio // TP cho lệnh bán
slLevelShort = close + outsideBarHeight * slRatio // SL cho lệnh bán
// Strategy logic
if (outsideBarCrossAbove)
strategy.entry("Buy", strategy.long)
strategy.exit("Take Profit/Stop Loss", "Buy", stop=slLevelLong, limit=tpLevelLong) // Thêm TP và SL
if (outsideBarCrossBelow)
strategy.entry("Sell", strategy.short)
strategy.exit("Take Profit/Stop Loss", "Sell", stop=slLevelShort, limit=tpLevelShort) // Thêm TP và SL
// Logic: Nếu lệnh Buy bị Stop Loss => Vào lệnh Sell
if (strategy.position_size > 0 and close <= slLevelLong)
strategy.close("Buy")
strategy.entry("Sell After Buy SL", strategy.short)
// Logic: Nếu lệnh Sell bị Stop Loss => Vào lệnh Buy
if (strategy.position_size < 0 and close >= slLevelShort)
strategy.close("Sell")
strategy.entry("Buy After Sell SL", strategy.long)
// Cảnh báo khi label Buy xuất hiện
alertcondition(condition=outsideBarCrossAbove, title="Label Buy Xuất Hiện", message="Label Buy xuất hiện tại giá: {{close}}")
// Cảnh báo khi label Sell xuất hiện
alertcondition(condition=outsideBarCrossBelow, title="Label Sell Xuất Hiện", message="Label Sell xuất hiện tại giá: {{close}}")
Giải thích sửa lỗi:
Loại bỏ gán plotshape vào biến:
Bạn không cần gán plotshape vào biến buyLabel hoặc sellLabel. Thay vào đó, bạn có thể sử dụng trực tiếp điều kiện outsideBarCrossAbove và outsideBarCrossBelow để tạo cảnh báo.
Sử dụng alertcondition:
alertcondition được sử dụng để tạo cảnh báo khi điều kiện outsideBarCrossAbove hoặc outsideBarCrossBelow được đáp ứng.
Kết quả:
Khi label Buy xuất hiện, cảnh báo "Label Buy xuất hiện tại giá: X" sẽ được kích hoạt.
Khi label Sell xuất hiện, cảnh báo "Label Sell xuất hiện tại giá: X" sẽ được kích hoạt.
Lưu ý:
Đảm bảo rằng bạn đã bật cảnh báo trong TradingView để nhận thông báo khi label xuất hiện.
Kiểm tra kỹ lưỡng chiến lược trên dữ liệu lịch sử trước khi sử dụng trong giao dịch thực tế.
New chat
1stderivative1st derivative
quadratic regression slope indicator updated for version 6 of trading view
9 and 21 EMA CrossoverIndicator using the popular 9 and 21 ema signal. Cross over indicate either long or short.
Weighted Currency Strength DashboardWeighted Currency Strength Indicator takes all of the currency pairs of a region to form weighted strength.
For example, GBPUSD
array.push(GBP_weights, 0.2) // GBPJPY
array.push(GBP_weights, 0.2) // GBPEUR
array.push(GBP_weights, 0.2) // GBPAUD
array.push(GBP_weights, 0.2) // GBPCAD
Custom Moving Averages (410, 130, 150, 770 Days)Custom Moving Averages: This refers to a set of moving averages calculated over specific time periods, tailored to unique analytical needs. The moving averages in this case are based on the following day intervals:
410-Day Moving Average: Tracks the trend over a long-term period of 410 days.
130-Day Moving Average: Represents a medium-term trend, offering insight into shorter fluctuations compared to the 410-day average.
150-Day Moving Average: Similar to the 130-day average but slightly longer, providing a nuanced view of medium-term movements.
770-Day Moving Average: Captures ultra-long-term trends, smoothing out the effects of seasonal or cyclical variations.
These moving averages are customized to provide a comprehensive view of trends across multiple time horizons, often used for specialized analysis in fields like finance, trading, or data science.
CLuceSalutemShort Description: This Pine Script combines the Gaussian Moving Average, Stochastic Oscillator, and VWAP to create a versatile trading indicator. It integrates ATR-based trailing stops and Fibonacci levels to enhance decision-making for both trend and momentum traders.
Detailed Description: The Gaussian Stochastic VWAP Strategy is designed for traders seeking a comprehensive tool that identifies trends, momentum shifts, and key price levels. The script features:
Gaussian Moving Average (GMA): Smooths price data for reliable trend detection.
Stochastic Oscillator (%K and %D): Highlights momentum shifts and overbought/oversold conditions.
VWAP with Bands: Tracks volume-weighted price averages with dynamic standard deviation bands for support and resistance.
ATR-Based Trailing Stops: Provides adaptive stop-loss levels for long and short trades.
Fibonacci Levels: Automatically plots key retracement levels for price targets and reversals.
Signal Alerts: Generates buy/sell signals based on stochastic crossovers and Gaussian trend alignment.
This indicator is versatile and works on various timeframes, making it suitable for scalpers, swing traders, and position traders.
Categories
Trend Analysis
The Gaussian Moving Average helps identify the direction of the market trend.
Momentum
Stochastic Oscillator highlights shifts in market momentum, assisting in entry and exit timing.
Support & Resistance
VWAP bands and Fibonacci levels provide clear areas of interest for price action.