OPEN-SOURCE SCRIPT

EMA Crossover + SuperTrend Retest

137
//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")

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.