Look at India VIX on two days. On 24 Nov 2025 it closed at 13.24. On 22 Apr 2026 it closed at 18.30, after standing at 12.25 on 4 Feb. A volatility rule tuned on the quiet autumn would meet that spring as a stranger. Walk forward testing is the method that makes a rule meet strangers on purpose. It fits the rule on one stretch of history, trades the next stretch it has never seen, then slides forward and does it again. This lesson sets out the method on the 300 sessions in the school's files, shows the four test windows they give and what each window holds, adds the purge, the embargo and the deflated Sharpe ratio, and says what the method cannot fix. The rule in the example is made up, and nothing here is a view on where Nifty goes.
3By the end you can
- Split data into fit and test parts and say when a test part stops being out of sample.
- Work out folds, tested sessions, efficiency and the purge and embargo cost for a walk forward run.
- Read a deflated Sharpe ratio and a probability of backtest overfitting, and name the Indian rule changes inside each fold.

The idea, plainly
What is out of sample testing?
Split the history in two. Fit the rule, and every parameter in it, on the first part. Then run it once on the second part, with nothing changed. The second part is out of sample: the rule has not seen it. The split has one strict law. The moment a result on the second part makes you change the rule, that part has become in sample, because it shaped the choice. A common way a backtest fails is a test set that was looked at before it was used. The lesson on biases explains why a version count matters, and a clean out of sample test is one guard against it.
What is walk forward testing?
A single split uses the test part once. Walk forward repeats the split along the calendar. Fit on a training window of 100 sessions, freeze the parameters, trade the next 50 sessions, record the result, then move the windows forward by 50 sessions and fit again. The test windows never overlap, and each is traded with parameters that were fitted only on the past. Joined end to end, they form one out of sample record. With 300 sessions this gives 4 folds, so 200 sessions are tested out of sample, 66.7% of the data. A single split that fits on 70% of the data tests 90.
Each fold fits first, freezes, and only then meets new data
Walk forward tests 66.7% of the sessions out of sample
Rolling or anchored, and how long a window?
A rolling window drops old data as it moves, so the fit follows recent markets and ignores the distant past. An anchored window keeps the start fixed and grows, so the fit leans on more data and reacts more slowly. Neither is correct in itself. The choice is a guess about whether the market's rules change, and both options should be written down before the run. Window length is the same trade: short windows adapt and fit noise, long windows are steadier and may fit a regime that has gone. A fold also needs enough trades to say anything. A weekly rule trades about 10 times in a test window of 50 sessions, far fewer than the trades a result needs.
Maths: folds, tested sessions and efficiency
Folds = (N − train)
÷ test
Tested = folds × test
Efficiency =
mean test result
÷ mean fit result
Here N is the number of sessions. With N = 300, train = 100 and test = 50, folds = 4, and tested sessions are 200. Efficiency compares what the rule earned on data it had not seen with what it earned on data it was fitted to. A value near one says the fit was not much flattered. A value near zero says it was. For an anchored window the training length at fold k is train plus (k − 1) times test, so the last fold here fits on 250 sessions where a rolling window still uses 100.
How much can one fold tell me?
Less than the table of test scores suggests. The Sharpe ratio is an estimate, and its error is large over a short window. For returns that are independent, the standard error of a Sharpe ratio measured on T periods is close to the square root of (1 + SR squared over 2) over T, where SR is the per-period ratio (Lo, 2002). Annualised for daily data, and with a true ratio of zero, the standard error is the square root of 252 over the number of sessions. For a test window of 50 sessions that is 2.2, and for all 300 sessions in the files it is 0.92. A test Sharpe ratio of one on one fold is therefore less than half a standard error from zero. Skew and fat tails make it worse, and Opdyke (2007) extends the formula to returns that have them.

Maths: how many years to see a Sharpe ratio
Years = (1 + SR² ÷ 2)
× (z ÷ SR)²
Here SR is the annual Sharpe ratio and z the one sided normal cut off, 1.645 at the five percent level. For an annual ratio of 0.5 the formula gives 12.2 years of independent returns. For 1.0 it gives 4.1 years, for 1.5 it gives 2.6, and for 2.0 it gives 2.0. A test window of 50 sessions is nowhere near these lengths. Lo (2002) also warns that multiplying a daily ratio by the square root of the sessions in a year is right only for independent returns, and overstates the ratio when returns are positively correlated.
What is leakage, and what is an embargo?
A trade that lasts days carries the end of the training window into the start of the test window: the last training trades are scored on prices from the test window, so the fit has seen part of the test. A feature built from a twenty day average does a milder version of the same, because the first test rows share most of their inputs with the last training rows. The remedy is an embargo, a gap between the two windows in which nothing is traded or scored, at least as long as the holding period and, to be careful, as long as the feature's window. An option position that runs to expiry needs the gap to reach to that expiry. It is also tidier to cut folds at expiries, so no trade is split across the boundary.
What are purging and embargoing in a split?
Walk forward puts the test window after the training window, so the only leak runs forward from the end of training. A cross validated split, which trains on both sides of a test block, leaks from both. Racine (2000) handled this for dependent data with hv block cross validation: remove v observations on each side of the test block from the training set. Lopez de Prado (2018) gives the finance version in two named steps. Purging drops every training observation whose label, the span from entry to exit of its trade, overlaps the test block. Embargoing also drops a margin of observations just after the test block from the training set, because serial correlation lets those later rows carry information about the block. Bergmeir and Benítez (2012) compared such blocked schemes with out of sample evaluation on the last part of a series and recommend the blocked form for time series, which uses all the data and avoids the theoretical problems of the plain scheme.
2 terms this section turns on
Maths: combinatorial purged cross validation
Splits = C(N, k)
Paths = C(N, k) × k ÷ N
Cut the history into N groups and take k of them as the test set, in every possible way. With N of 6 and k of 2 that is 15 splits, and since each group is tested in the same number of splits, the test groups can be stitched into 5 different full length out of sample paths. With N of 10 and k of 2 it is 45 splits and 9 paths. The point is to replace one out of sample number with a spread of them. The groups are still purged and embargoed at each edge. All paths share one history, so the spread is real but narrower than independent samples would give.
Read one more paragraph, 78 words
The cost is small and the leak it closes is not. Take 300 sessions in five folds, so a test block of 60 sessions, a trade held for 5 sessions and an embargo of 5. A block in the middle loses 5 training sessions before it, whose trades would end inside the block, and 5 after it. That is 10 of the 240 training sessions, 4.2%. Skipping it costs nothing on paper and flatters the fit.
How many tries, and what does the deflated Sharpe ratio say?
Walk forward guards the fit. It does not guard the choice among the rules tried. If 100 variants of a rule are each walked forward and the best test record is shown, that record is a maximum of 100 noisy numbers and has the bias of one. Bailey and Lopez de Prado (2014) correct for it. Their deflated Sharpe ratio is the probability that the true Sharpe ratio exceeds a benchmark that rises with the number of trials, and it also adjusts for the length of the record and for skew and fat tails. The benchmark is the Sharpe ratio the best of 100 rules with no skill would be expected to show.
Maths: the deflated Sharpe ratio
SR0 = s × [(1 − γ) × z1
+ γ × z2]
z1 = Φ⁻¹(1 − 1/N)
z2 = Φ⁻¹(1 − 1/(N × e))
DSR = Φ[(SR − SR0) ×
√(T − 1) ÷ den]
den = √(1 − g3 × SR
+ (g4 − 1) ÷ 4 × SR²)
Here s is the standard deviation of the Sharpe ratios across the N trials, γ is Euler's constant, 0.5772, Φ the normal distribution, T the number of returns, and g3 and g4 the skew and kurtosis of the returns. All Sharpe ratios in the last line are per period, not annualised. The first line is an approximation to the expected maximum of N normal draws. At N of 100, z1 is 2.33 and z2 is 2.68, so it reaches 2.53 standard deviations, against 1.57 at ten trials.
| Step | Value |
|---|---|
| Best Sharpe ratio, per period | 0.101 |
| Expected best of the trials, annual (SR0) | 1.27 |
| SR0 per period | 0.080 |
| Denominator from skew and kurtosis | 1.044 |
| z against zero, probability | 3.06, 99.9% |
| z against SR0, deflated Sharpe ratio | 0.64, 74% |
Read 2 more paragraphs, 151 words
A made up case. A rule is the best of 100 variants, each tested on 1,008 daily returns, about four years. The best has an annual Sharpe ratio of 1.6, a skew of −0.8 and a kurtosis of 5, the signature of a seller of options. The trials' Sharpe ratios have a standard deviation of 0.5 a year. Then SR0 is 0.5 times 2.53, or 1.27 a year. Against zero the best rule looks decisive: its z statistic is 3.06, a probability of 99.9%. Against SR0, z falls to 0.64 and the deflated ratio to 74%. That is below the usual 95% bar. The rule would need an annual ratio of about 2.1 to pass.
Model, not market data: the inputs are the five assumptions named in the paragraph above, and the arithmetic is the formula in the box, with 252 sessions in a year.

What is the probability of backtest overfitting?
The deflated ratio needs the number of trials, and that is often not known. Bailey, Borwein, Lopez de Prado and Zhu (2016) measure overfitting from the trials' returns alone. Lay the return series of all N candidates side by side. Cut the dates into 10 equal slices. Choose half of them as the training set and the rest as the test set, in every possible way: 252 ways for 10 slices. In each way pick the candidate with the best training Sharpe ratio and find its rank among all candidates on the test slices. The probability of backtest overfitting is the share of splits in which that candidate ranks below the median out of sample. They call the scheme combinatorially symmetric cross validation.
A real edge of Sharpe two cuts the overfitting measure to about a quarter
Read one more paragraph, 117 words
A model run shows how it behaves. Make 20 candidates of 1,008 daily returns each, with 10 slices and 252 splits, and repeat on 30 seeded data sets. If every candidate is noise the average probability is 55%, close to a coin toss, and single data sets range from 21% to 90%. Give one candidate a real annual Sharpe ratio of 1.0 and the average falls to 44%; at 2.0 it falls to 14%. One data set gives a noisy reading, so the measure is best read as an average over resamples of the data, not as a single number. The chart shows the three averages as 55, 44 and 14 percent.
Does it suit options?
It fits, with three extra cares. An option trade ends at an expiry, so a fold should begin and end on expiry dates, and no position may be open across a boundary. The contract changes inside the history: the lot, the expiry day and the charges in the lesson on options backtests all differ between folds, so every fold needs its own table of rules. And volatility regimes are the largest source of difference between windows. A short volatility rule fitted in a calm fold will meet a spike in another. The method does not hide that. It shows it, one fold at a time. For a weekly straddle sold about 5 sessions before its expiry, the embargo is that many sessions, and a fold that ends on the Tuesday of an expiry week needs the next fold to start after the next expiry.
How do I read the result?
Three checks, in this order. First, the stitched test record, judged by the measures in strategy metrics, not by the training fits. Second, the efficiency ratio: a rule whose test results are a small part of its fit results was mostly fitted. Third, and the one I look at before the total, the parameter that wins each fold. If it sits near the same value in every fold, the rule has found something stable. If it jumps from fold to fold, the fit is chasing noise. A rule can show a good stitched record and still fail this third check.
Four test windows come out of the school's 300 sessions
- Test 1
Fit on 1 Jul to 24 Nov 2025, then trade 25 Nov 2025 to 4 Feb 2026.
- Test 2
Fit on 11 Sep 2025 to 4 Feb 2026, then trade 5 Feb to 22 Apr 2026.
- Test 3
Fit on 25 Nov 2025 to 22 Apr 2026, then trade 23 Apr to 6 Jul 2026.
- Test 4
Fit on 5 Feb to 6 Jul 2026, then trade 7 Jul to 15 Sep 2026.

Where does a final holdout go?
Walk forward folds are used to build and tune. Keep a last stretch of history outside all of them, a final holdout, and look at it once, after the rule and its windows are frozen. The folds may be reused as often as the work needs, since they are part of the fit. The holdout may be spent once. If it fails, the honest options are to stop or to start a new rule with a new holdout. Going back to retune against the same holdout makes it a fold.
What do the rules of each window do to a fold?
Every fold in the files sits across a rule change, and a rule fitted in one fold meets the next rule set in the test window. The table lists what moved inside each window or its fit, with the circular that moved it.
| Window | What changed | Source |
|---|---|---|
| Fit for test 1, 1 Jul to 24 Nov 2025 | Weekly and monthly Nifty expiries move from Thursday to Tuesday for contracts expiring from 1 Sep 2025. Lot 75 | NSE/FAOP/68747 |
| Test 1, 25 Nov 2025 to 4 Feb 2026 | Lot falls from 75 to 65, first on the weekly expiry of 6 Jan 2026 | NSE/FAOP/70616 |
| Test 2, 5 Feb to 22 Apr 2026 | On 1 Mar 2026 the IPFT contribution was folded into the option transaction charge (Rs 3,503 plus IPFT became Rs 3,553 per crore), so the total outflow did not change; a ledger that tracks the two lines separately has to follow the split. STT on a sold option 0.10% to 0.15% and on exercise 0.125% to 0.15% on 1 Apr 2026. The retail algo framework applies to all brokers from 1 Apr 2026 | NSE/FA/73061, NSE/FATAX/73524, SEBI/HO/MIRSD/MIRSD-PoD/P/CIR/2025/132 |
| Test 3, 23 Apr to 6 Jul 2026 | Past Risk and Return Verification Agency begins work on 4 May 2026 | SEBI circular of 3 Aug 2026 |
| Test 4, 7 Jul to 15 Sep 2026 | Closing auction session starts in the cash market on 3 Aug 2026, which sets the index close that settles expiries. Pre-open changes from 7 Sep 2026 | SEBI HO/47/11/11(3)2025-MRD-POD2/I/2765/2026 |
Read one more paragraph, 79 words
A fitted position size is a case in point. At the spot of 2 Feb 2026, one lot of 75 units holds Rs 18,81,630 of notional and one lot of 65 units holds Rs 16,30,746. A size fitted as two lots in the old lot holds Rs 5,01,768 more notional than two lots of the new one, a change in risk that no parameter of the rule caused. Fit sizes in notional or in premium, not in lots.
If I refit a registered algo, is that a change in logic?
For an algo that trades live, walk forward is also a compliance question. Under the NSE modalities of 22 Jul 2025 (NSE/INVG/69255, para 9), the changes to an algo supplied by an algo provider that need re-registration include a change in the logic governing the algo, a version change and a change in the broker's API, and no modification is allowed to a registered black box algo: a change in its logic is a fresh registration. Registration of a new algo takes up to 10 working days from a complete application, and 7 for execution algos (para 5.2). Whether a monthly refit of one parameter counts as a change in logic is for the broker and the exchange to say, not for this page. One design that eases the question is to state the rule, the parameter ranges and the refit schedule in the registration papers, though only the exchange can say what it accepts.
Two terms to hold on to from 19.7
What does the research say?
The statistics behind the method are settled, and the finance versions are recent. Lo (2002) gives the sampling error of the Sharpe ratio. Bailey and Lopez de Prado (2014) turn it into the deflated ratio, and Bailey, Borwein, Lopez de Prado and Zhu (2014, 2016) show how easily a short search overfits and measure it. Harvey and Liu (2015) convert a Sharpe ratio to a t-ratio and discount it for the number of tests, and argue that the haircut is not a flat half: heavier for marginal ratios, lighter for large ones. For the split itself, Racine (2000), Bergmeir and Benítez (2012) and the survey of Arlot and Celisse (2010) are the base. None of them says walk forward testing proves a rule. They say it is a better guard than a single split, and that the guard is only as strong as the count of tries and the length of the record.
How do I lay out my own folds?
Take any series of dates, such as the school's files, and lay out your own folds before running anything. Write down five choices: the training length, the test length, the step, the gap and whether the window rolls or anchors. Count the sessions in each fold and the trades you expect in each test window. Work out how many folds you get and what share of the data is tested out of sample. Then ask whether the trades per fold are enough to say anything. If they are not, no choice of windows will fix it, and the answer is a longer history or a rule that trades more often. Then write down the number of variants you will try, because the deflated ratio will ask for it.
Where this section sits in module 19.7
Stretch: from folds to a research record
Monte Carlo and bootstrap asks how much of the stitched record could be luck. Backtest overfitting works the deflated ratio and the overfitting probability on a larger set of trials, and financial machine learning carries purging and embargoing into models with many features.
Worked example: four folds of a made up rule
The test windows are real and the rule is not. Each window is a different market. The table gives, for each, the move in Nifty over the window and India VIX at its start and end. A rule fitted before a window never saw it.
| Test window | Nifty | VIX, start to end |
|---|---|---|
| 1: 25 Nov to 4 Feb | −0.7% | 13.24 to 12.25 |
| 2: 5 Feb to 22 Apr | −5.4% | 12.25 to 18.30 |
| 3: 23 Apr to 6 Jul | 0.2% | 18.30 to 11.82 |
| 4: 7 Jul to 15 Sep | −5.4% | 11.82 to 13.43 |
The four test windows meet four different volatility regimes
| Made up fold | Fit | Test | Lookback |
|---|---|---|---|
| 1 | 1.8 | 0.9 | 10 |
| 2 | 2.1 | 0.1 | 40 |
| 3 | 1.6 | 1.1 | 15 |
| 4 | 2.0 | 0.2 | 60 |
Each fold scored lower on data it had not seen
Read 3 more paragraphs, 193 words
Window 2 holds the spring of 2026, when VIX climbed from 12.25 to 18.30. Window 3 begins in that stress and ends calm. The same rule faces four temperaments, and a single split would have tested it on one of them.
Now the rule's own numbers, all made up. The fit score of each fold is the rule's Sharpe ratio on its training window. The test score is the Sharpe ratio on the window after it. The last column is the fitted parameter, a lookback in sessions.
The fit scores average 1.88 and the test scores 0.58, so efficiency is 0.31. Every fold paid for being tested, which is the usual shape: a fitted rule looks better than it is. The lookback wandered between 10 and 60 sessions, which is the third check failing. A rule whose best parameter changes sixfold from fold to fold has no single setting worth trusting. The scores themselves also carry the error worked out above: a test Sharpe of 1.1 on 50 sessions has a standard error near 2.2, so the gap between 0.1 and 1.1 is smaller than the noise in either.
The common mistake
The belief: I used walk forward testing, so the result is out of sample.
It is only as out of sample as the discipline behind it. If the rule, the window lengths or the markets changed after a look at the folds, the folds joined the fit and the run is in sample at one remove. Walk forward also reuses one history. It cannot make the data longer, and it cannot add a crash that did not happen. Four specific errors follow. First, no embargo on a weekly rule: the last 5 training sessions score trades that end inside the test window, and the fit has seen part of the answer. Second, reporting the best of 100 variants without the count: a Sharpe ratio of 1.6 that looks like 99.9% against zero is 74% after the trials. Third, sizing in lots across the lot change: a lot of 75 units at the 2 Feb 2026 spot holds Rs 18,81,630 and a lot of 65 holds Rs 16,30,746, so a two lot position differs by Rs 5,01,768 of notional with no change in the rule. Fourth, trusting a fold of 50 sessions: its Sharpe ratio has a standard error near 2.2. Keep a final holdout, a stretch of data nobody touches until the rule is frozen, and spend it once. A pass there is still a record of the past. SEBI asks registered investment advisers and research analysts who communicate verified past performance to enrol with the Past Risk and Return Verification Agency (SEBI circular of 3 Aug 2026). Monte Carlo and bootstrap asks how much of the result could be luck.

What I'd keep from this
- A test part is out of sample only until a result changes the rule.
- Walk forward repeats fit, freeze and test along the calendar.
- Fifty sessions give a Sharpe ratio a standard error above two.
- Cut an embargo gap as long as the holding period or feature window.
- The best of many tries needs a deflated Sharpe ratio, not a raw one.
- Every fold sits across a rule change: lots, STT, charges, settlement.
Where this section sits in module 19.7
Before you trade. Derivatives trading carries a high risk of loss. SEBI's study "Profitability of Individual Traders in the Equity Derivatives Segment (FY25 to FY26)" (August 2026) found that 87.7% of individual traders in equity F&O made net losses in FY26, with aggregate net losses of Rs 91,685 crore. Read the SEBI study