//@version=5
indicator("Custom Gainz Algo v2 Alpha", overlay=true)
// INPUTS
fastLength = input.int(14, title="Fast EMA Length")
slowLength = input.int(50, title="Slow EMA Length")
atrLength = input.int(14, title="ATR Length")
mult = input.float(1.5, title="ATR Multiplier", step=0.1)
// INDICATORS
emafast = ta.ema(close, fastLength)
emaslow = ta.ema(close, slowLength)
atr = ta.atr(atrLength)
// TREND LOGIC
bullTrend = emafast > emaslow
bearTrend = emafast < emaslow
// ENTRY SIGNALS
buysignal = ta.crossover(emafast, emaslow)
sellsiganl = ta.crossunder(emafast, emaslow)
// TRAILING STOP
longstop = close - atr * mult
shortstop = close + atr * mult
// PLOT EMAS
plot(emafast, color=color.teal, title="Fast EMA")
plot(emaslow, color=color.orange, title="Slow EMA")
// PLOT SIGNALS
plotshape(buysignal, title="Buy Signal", location=location.belowbar,
color=color.green, style=shape.labelup, text="Buy")
plotshape(sellsiganl, title="Sell Signal", location=location.abovebar,
color=color.red, style=shape.labeldown, text="Sell")
// PLOT STOPS
plot(bullTrend ? longstop : na, title="Long Stop", color=color.green,
style=plot.style_linebr)
plot(bearTrend ? shortstop : na, title="Short Stop", color=color.red,
style=plot.style_linebr)