//@version=5
indicator("Smart Buy/Sell Signal (EMA + RSI + MACD)", overlay=true)
// === EMA Crossover ===
emaFast = ta.ema(close, 9)
emaSlow = ta.ema(close, 21)
emaBuy = ta.crossover(emaFast, emaSlow)
emaSell = ta.crossunder(emaFast, emaSlow)
// === RSI Filter ===
rsi = ta.rsi(close, 14)
rsiBuy = rsi < 35
rsiSell = rsi > 65
// === MACD Filter ===
= ta.macd(close, 12, 26, 9)
macdBuy = hist > 0
macdSell = hist < 0
// === Final Buy/Sell Conditions ===
buySignal = emaBuy and rsiBuy and macdBuy
sellSignal = emaSell and rsiSell and macdSell
// === Plot Buy/Sell Labels ===
plotshape(buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// === Optional: Plot EMAs ===
plot(emaFast, title="EMA 9", color=color.orange)
plot(emaSlow, title="EMA 21", color=color.blue)