Smartmoney11

168
//version=5
indicator("ADA 4H Trend-Following Alerts", overlay=true)

// === INPUTS ===
fastLen = input.int(21, "MACD Fast Length")
slowLen = input.int(50, "MACD Slow Length")
signalLen = input.int(9, "MACD Signal Length")

rsiLen = input.int(14, "RSI Length")
stochLen = input.int(14, "Stoch RSI Length")
kLen = input.int(3, "Stoch K")
dLen = input.int(3, "Stoch D")

useDailyTrend = input.bool(true, "Require Daily Uptrend Filter?")
emaFilterLen = input.int(50, "Daily EMA Length")

// === MACD ===
[macdLine, signalLine, _] = ta.macd(close, fastLen, slowLen, signalLen)
macdCrossUp = ta.crossover(macdLine, signalLine)
macdCrossDown = ta.crossunder(macdLine, signalLine)

// === StochRSI ===
rsi = ta.rsi(close, rsiLen)
rsiMin = ta.lowest(rsi, stochLen)
rsiMax = ta.highest(rsi, stochLen)
stochRsi = (rsi - rsiMin) / (rsiMax - rsiMin)
k = ta.sma(stochRsi, kLen)
d = ta.sma(k, dLen)

stochBounce = k > 0.2 and ta.cross(k, 0.2)

// === Daily Trend Filter ===
dailyEma = request.security(syminfo.tickerid, "1D", ta.ema(close, emaFilterLen))
dailyTrendUp = close > dailyEma

// === SIGNAL CONDITIONS ===
longSignal = macdCrossUp and stochBounce and (not useDailyTrend or dailyTrendUp)
exitSignal = macdCrossDown

// === ALERTS ===
alertcondition(longSignal, title="Buy Signal", message="ADA 4H BUY: MACD + StochRSI signal")
alertcondition(exitSignal, title="Sell Signal", message="ADA 4H SELL: MACD cross down")

// === PLOTS ===
plotshape(longSignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(exitSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.