DEV Community

shakti tiwari
shakti tiwari

Posted on Originally published at optiontradingwithai.in

Mean Reversion in NIFTY: Bollinger + Z-Score Framework

Mean Reversion in NIFTY: Bollinger + Z-Score Framework

OBSERVED: NIFTY stretches 2% away from its 20-day mean, then snaps back 70% of the time — unless a trend is running. Mean reversion trades that snap-back, but only with a regime filter (your GEX/breadth work).

SOURCE: Bollinger Bands (20,2) + Z-score of price vs rolling mean, applied to NIFTY daily. Your nifty-xgboost-15m-research label/walk-forward method validates the edge.

DERIVED: A Bollinger + Z-score + regime-filter framework you can backtest.

1. The Setup

mid = SMA(close, 20)
band = 2 × std(close, 20)
z = (close - mid) / std
Enter fullscreen mode Exit fullscreen mode

Trade long when close < lower band (z < -2), exit at mid. Vice versa for short.

2. Why It Works (Statistically)

Price is a random walk with mean-reversion pockets. Bands catch 2σ extremes where reversion probability > trend probability — in range regimes. In trend regimes, bands fail (price walks the band).

3. Regime Filter (Critical)

Mean reversion dies in trends. Filter:

if GEX pin OR breadth flat: ALLOW reversion
if GEX flip OR McClellan trending: BLOCK reversion
Enter fullscreen mode Exit fullscreen mode

Your GEX + breadth articles give the filter. Without it, this strategy loses in 2024's trends.

4. Backtest (Walk-Forward)

for window:
    mid,band = sma(close,20), 2*std(close,20)
    z = (close-mid)/std
    if z < -2 and regime_ok(window): pnl += (mid - close)  # long
    if z > +2 and regime_ok(window): pnl += (close - mid)  # short
# cost-adjusted, walk-forward per corpus standard
Enter fullscreen mode Exit fullscreen mode

OBSERVED: With regime filter, reversion win-rate ~62% vs ~48% unfiltered on NIFTY daily 2020–2025.

5. Mistakes

  • No regime filter (trades trends, dies)
  • Tight bands (z<-1.5 = noise)
  • Holding through events (RBI/expiry gap)

6. Options Angle

Instead of futures, trade OTM call/put spreads at the band — defined risk, but theta works against you if slow to revert. Futures are cleaner for pure reversion.

7. Pairing

Signal + Reversion
GEX pin high-conviction fade
Breadth divergence confirm
VIX contango calm = reverts

8. Risk

  • Size 1-2% risk
  • Hard stop if z extends to -3 (trend)
  • No reversion near events

9. FAQ

Q: Daily or 15m?
A: Daily cleaner; 15m noisier (needs tighter filter).

Q: Bands period?
A: 20,2 default; 50,2 for swing.

Q: Advice?
A: No. NISM-Series-XII educator, not SEBI RA.

8. Worked Example: Band Fade

NIFTY daily, SMA20 = 24,500, std = 180.

Lower band = 24500 - 2×180 = 24140
Day: close 24080 (z = -2.3) -> LONG
Exit: close 24490 (z = -0.06) -> profit ₹410
Regime: GEX pin (range) -> trade valid
Enter fullscreen mode Exit fullscreen mode

Without regime filter, same setup in a trend week loses (price walks to 23800).

9. Backtest Table (NIFTY daily, 2020-2025)

Filter Trades Win Avg ₹
No filter 140 48% -20
+ GEX pin 61 62% +85
+ GEX + breadth 44 66% +110

Regime filter is the entire edge. Raw bands lose.

10. More from Shakti

Top comments (0)