Put Spread Signals Daily v5 (NO ta.sum)//@version=5
indicator("Put Spread Signals Daily v5 (NO ta.sum)", overlay=true)
// Inputs
ma20Len = input.int(20, "MA20")
ma50Len = input.int(50, "MA50")
ma200Len = input.int(200, "MA200")
pullbackPct = input.float(0.01, "Pullback near MA20 (1%=0.01)", step=0.005)
minRedDays = input.int(1, "Min red days (last 5)", minval=0, maxval=5)
stopBelow200Pct = input.float(0.005, "Stop below MA200 %", step=0.0025)
// MAs
ma20 = ta.sma(close, ma20Len)
ma50 = ta.sma(close, ma50Len)
ma200 = ta.sma(close, ma200Len)
// Trend + pullback
bullTrend = close > ma50 and close > ma200 and ma50 > ma200
nearMA20 = close <= ma20 * (1 + pullbackPct)
// Red candle count last 5 bars (NO ta.sum)
red0 = close < open ? 1 : 0
red1 = close < open ? 1 : 0
red2 = close < open ? 1 : 0
red3 = close < open ? 1 : 0
red4 = close < open ? 1 : 0
redCount = red0 + red1 + red2 + red3 + red4
hasMinRed = redCount >= minRedDays
// Bounce
bounce = close > open and close > close
// Signals
enter = bullTrend and nearMA20 and hasMinRed and bounce
takeProfit = ta.crossover(close, ma20)
stopOut = close < ma200 * (1 - stopBelow200Pct)
// Plots
plot(ma20, "MA20", linewidth=2)
plot(ma50, "MA50", linewidth=2)
plot(ma200, "MA200", linewidth=2)
plotshape(enter, title="ENTER", style=shape.labelup, location=location.belowbar, text="ENTER", size=size.small)
plotshape(takeProfit, title="EXIT_TP", style=shape.labeldown, location=location.abovebar, text="TP", size=size.small)
plotshape(stopOut, title="EXIT_STOP", style=shape.labeldown, location=location.abovebar, text="STOP", size=size.small)
// Alerts
alertcondition(enter, title="ENTER Alert", message="ENTER: Trend up + pullback near MA20 + bounce. Consider selling put credit spread (30-45 DTE).")
alertcondition(takeProfit, title="EXIT TP Alert", message="EXIT TP: Price reclaimed MA20. Consider taking profit.")
alertcondition(stopOut, title="EXIT STOP Alert", message="EXIT STOP: Close below MA200 threshold. Consider closing/rolling.")
Pine Script® indicator






















