OPEN-SOURCE SCRIPT
EMA Crossover + SuperTrend Retest

//version=5
indicator("EMA Crossover + SuperTrend Retest", overlay=true)
// Inputs for SuperTrend
atrLength = input.int(10, "ATR Length", minval=1)
Factor = input.float(3.0, "SuperTrend Multiplier", step=0.1)
// Calculate EMAs
ema13 = ta.ema(close, 13)
ema50 = ta.ema(close, 50)
ema200 = ta.ema(close, 200)
// Calculate SuperTrend
[supertrend, direction] = ta.supertrend(Factor, atrLength)
// Plot EMAs
plot(ema13, "EMA 13", color=color.new(#FF6D00, 0))
plot(ema50, "EMA 50", color=color.new(#2962FF, 0))
plot(ema200, "EMA 200", color=color.new(#00BFA5, 0))
// Plot SuperTrend
plot(supertrend, "SuperTrend",
color=direction == 1 ? color.rgb(230, 13, 13) : color.rgb(17, 255, 0),
linewidth=2)
// Trend Conditions
uptrendFilter = ema50 > ema200 and close > supertrend
downtrendFilter = ema50 < ema200 and close < supertrend
// Crossover Conditions with Trend Filter
bullishCross = ta.crossover(ema13, ema50) and uptrendFilter
bearishCross = ta.crossunder(ema13, ema50) and downtrendFilter
// Retest Conditions (Both EMAs and SuperTrend)
bullishRetest = bullishCross and
(low <= ema50) and
(low <= ema200) and
(low <= supertrend)
bearishRetest = bearishCross and
(high >= ema50) and
(high >= ema200) and
(high >= supertrend)
// Plot Signals
plotshape(bullishRetest, "Bullish Signal", shape.triangleup,
location.belowbar, color=color.green, size=size.small)
plotshape(bearishRetest, "Bearish Signal", shape.triangledown,
location.abovebar, color=color.red, size=size.small)
// Alert Conditions
alertcondition(bullishRetest, "Bullish Alert",
"EMA13↑50 + Retest 50/200/SuperTrend")
alertcondition(bearishRetest, "Bearish Alert",
"EMA13↓50 + Retest 50/200/SuperTrend")
indicator("EMA Crossover + SuperTrend Retest", overlay=true)
// Inputs for SuperTrend
atrLength = input.int(10, "ATR Length", minval=1)
Factor = input.float(3.0, "SuperTrend Multiplier", step=0.1)
// Calculate EMAs
ema13 = ta.ema(close, 13)
ema50 = ta.ema(close, 50)
ema200 = ta.ema(close, 200)
// Calculate SuperTrend
[supertrend, direction] = ta.supertrend(Factor, atrLength)
// Plot EMAs
plot(ema13, "EMA 13", color=color.new(#FF6D00, 0))
plot(ema50, "EMA 50", color=color.new(#2962FF, 0))
plot(ema200, "EMA 200", color=color.new(#00BFA5, 0))
// Plot SuperTrend
plot(supertrend, "SuperTrend",
color=direction == 1 ? color.rgb(230, 13, 13) : color.rgb(17, 255, 0),
linewidth=2)
// Trend Conditions
uptrendFilter = ema50 > ema200 and close > supertrend
downtrendFilter = ema50 < ema200 and close < supertrend
// Crossover Conditions with Trend Filter
bullishCross = ta.crossover(ema13, ema50) and uptrendFilter
bearishCross = ta.crossunder(ema13, ema50) and downtrendFilter
// Retest Conditions (Both EMAs and SuperTrend)
bullishRetest = bullishCross and
(low <= ema50) and
(low <= ema200) and
(low <= supertrend)
bearishRetest = bearishCross and
(high >= ema50) and
(high >= ema200) and
(high >= supertrend)
// Plot Signals
plotshape(bullishRetest, "Bullish Signal", shape.triangleup,
location.belowbar, color=color.green, size=size.small)
plotshape(bearishRetest, "Bearish Signal", shape.triangledown,
location.abovebar, color=color.red, size=size.small)
// Alert Conditions
alertcondition(bullishRetest, "Bullish Alert",
"EMA13↑50 + Retest 50/200/SuperTrend")
alertcondition(bearishRetest, "Bearish Alert",
"EMA13↓50 + Retest 50/200/SuperTrend")
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。