All work
Pine Script

FVG + Order-Block Retest Strategy with Honest Regime Filtering

A Pine v6 zone-retest strategy for Nifty and BankNifty where plain parameter sweeps were shown to curve-fit and only regime-filtered settings survived holdout.

Python engine matched the TradingView tester within 0.2 percent, 1.75 million regime-filter combinations, walk-forward and Monte Carlo, a documented null baseline showing half the edge is drift, and a Pine trap discovered in exit ordering.

FVG + Order-Block Retest Strategy with Honest Regime Filtering — illustration
What makes it serious
  • Engine matched the TV tester within 0.2%
  • Plain sweep exposed as curve-fit on all four datasets
  • Regime-filtered setting robust across 5,078 variants
  • Null baseline reported alongside the result

Fair-value gaps and order blocks are popular, so this project asked whether a retest strategy on Indian index futures has any measurable edge. A Python engine replicated the Pine logic and was validated against the TradingView Strategy Tester on 318 positions within 0.2 percent once fills mirrored the tester's path rules. Then the sweeps began, and the first finding was negative: honest in-sample selection failed the holdout on all four datasets, and rolling walk-forward was mostly negative.

A second round added regime filters (session VWAP, EMA, ADX, ATR, time windows, direction) over 1.75 million combinations. One family survived: long-only afternoon entries above session VWAP on Nifty 15-minute, with training and holdout profit factors that agree and 89 percent of neighbouring variants profitable out of sample. The report also states that a matched null (random afternoon longs above VWAP) already captures half of that edge, and that BankNifty never reached the bar.

Two engineering lessons are recorded for reuse: zone strategies must cap risk in ATR terms and add a time stop or a giant zone leaves a trade open for months and skews the sweep; and in Pine, calling cancel-all after close-all cancels the close itself, so time and end-of-day exits silently never fire.

Backtest research; shared as engineering work, not financial advice.

How it works

  1. Extract Nifty and BankNifty bars from the chart
  2. Replicate the Pine strategy in Python and verify against the tester
  3. Sweep core parameters, then regime filters, with holdout and walk-forward
  4. Compare winners to a matched null baseline
  5. Set Pine defaults to the surviving setting and attach to the chart
Stack
Pine Script v6PythonNumPyTradingView DesktopCDP

Software and automation are infrastructure, not financial advice. No performance guarantees. Every live system needs staged testing, risk limits, and owner approval.

#pine-script#fvg#order-block#nifty#walk-forward#research