📘 Introduction
This strategy combines the classic moving average crossover (SMA 20 and EMA 50) with powerful filters like RSI, volume, and support/resistance levels. It is designed for traders who want more accurate entries and fewer false signals — especially in volatile markets like crypto or stocks.
✅ Why Use This Strategy?
This script aims to:
- Reduce false signals from raw MA crossovers
- Filter trades using momentum (RSI)
- Require volume confirmation for shorts
- Avoid trades near strong support/resistance
- Optionally confirm entries with the previous candle
🧠 Strategy Logic
- Long Entry occurs when:
- SMA 20 crosses above EMA 50
- RSI is below 80 (to avoid overbought entries)
- Optional: Previous candle is bullish
- Short Entry occurs when:
- SMA 20 crosses below EMA 50
- RSI is above 30 (to avoid shorting oversold)
- Price is above support level
- Previous candle is bearish
- Volume is above average
🧾 Pine Script Code:
//@version=5
indicator("Advanced Strategy with Momentum & Support Filters", overlay=true)
// Inputs
smaLength = input.int(20, title="SMA Length")
emaLength = input.int(50, title="EMA Length")
rsiPeriod = input.int(14, title="RSI Period")
// Calculations
smaValue = ta.sma(close, smaLength)
emaValue = ta.ema(close, emaLength)
rsiValue = ta.rsi(close, rsiPeriod)
volMA = ta.sma(volume, 20)
// Manual Support/Resistance levels
supportLevel = input.float(2500, title="Support Level")
resistanceLevel = input.float(2700, title="Resistance Level")
// Crossover logic
crossUp = ta.crossover(smaValue, emaValue)
crossDown = ta.crossunder(smaValue, emaValue)
// Momentum filters
volFilterShort = (volume > volMA) and (close < open) // Volume + Bearish candle
// Entry signals
longSignalRaw = crossUp and rsiValue < 80
longSignalConfirmed = longSignalRaw // Simplified: Removed prior candle condition
shortSignalRaw = crossDown and rsiValue > 30 and (close > supportLevel)
shortSignalConfirmed = shortSignalRaw and close[1] < open[1] and volFilterShort
// Plots
plot(smaValue, color=color.orange, title="SMA 20")
plot(emaValue, color=color.blue, title="EMA 50")
hline(supportLevel, "Support", color=color.green, linestyle=hline.style_dashed)
hline(resistanceLevel, "Resistance", color=color.red, linestyle=hline.style_dashed)
plotshape(longSignalConfirmed, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(shortSignalConfirmed, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// Alerts
alertcondition(longSignalConfirmed, title="Long Signal", message="📈 Long entry confirmed on {{ticker}}")
alertcondition(shortSignalConfirmed, title="Short Signal", message="📉 Short entry confirmed on {{ticker}}")
How to Use It:
- Go to TradingView
- Open the Pine Editor
- Paste the code and click Add to Chart
- You’ll see:
- SMA/EMA crossover lines
- Support/resistance levels
- Clear BUY/SELL labels when conditions are met
🎯 Pro Tips
- Adjust support/resistance levels manually based on your technical analysis.
- Combine with higher timeframe confirmation or price action (like breakouts or candlestick patterns).
- Add stop-loss and take-profit automation if you’re using alerts/webhooks.