OPEN-SOURCE SCRIPT

Anti-PDT Swing Trade Signals

27
//version=5
indicator("Anti-PDT Swing Trade Signals", overlay=true)

// === User Inputs ===
priceLimit = input.float(25, "Max Price ($)", minval=1)
minVolume = input.int(200000, "Min Avg Volume (10D)", minval=1)

// === Indicators ===
sma20 = ta.sma(close, 20)
sma50 = ta.sma(close, 50)
macdLine = ta.ema(close, 12) - ta.ema(close, 26)
signalLine = ta.ema(macdLine, 9)
rsi = ta.rsi(close, 14)
avgVolume = ta.sma(volume, 10)

// === Conditions ===
priceFilter = close <= priceLimit
volumeFilter = avgVolume >= minVolume
rsiFilter = ta.crossover(rsi, 40)
macdFilter = ta.crossover(macdLine, signalLine)
smaFilter = close > sma20 and close > sma50
momentumFilter = close > close[5] * 1.03 and close < close[5] * 1.10

// === Day Filter ===
isMonWedFri = dayofweek == dayofweek.monday or dayofweek == dayofweek.wednesday or dayofweek == dayofweek.friday

entryCondition = priceFilter and volumeFilter and rsiFilter and macdFilter and smaFilter and momentumFilter and isMonWedFri

// === Alerts & Visuals ===
plotshape(entryCondition, title="BUY", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
alertcondition(entryCondition, title="BUY Alert", message="BUY Signal: {{ticker}} meets swing trading entry criteria.")
plot(sma20, color=color.orange)
plot(sma50, color=color.blue)

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.