---
title: "Walk Forward Testing: Out of Sample, Folds, Embargo"
description: "How walk forward testing fits a rule on one window and trades the next, shown on four test windows from NSE data, with efficiency, leakage and its limits."
source_url: "https://www.rupeecase.com/learn/path-19/module-19-7-walk-forward-testing"
---

[Path 19 7 of 16](/learn/path-19/)Walk forward and out of sample testing[Next 19.8](/learn/path-19/module-19-8-monte-carlo-and-bootstrap)

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, 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

1. Split data into fit and test parts and say when a test part stops being out of sample.
2. Work out folds, tested sessions and efficiency for a walk forward run.
3. Name leakage, an embargo and the signs that a fit is chasing noise.

Watch in the terminal: what are the four lead figures? A short tutorial on sample data.

## 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](/learn/path-19/module-19-1-backtest-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

The loop repeats until the history runs out. The joined test windows are the out of sample record. The training window may roll forward, or anchor at the start and grow. Source: RupeeCase illustration of walk forward testing. As of 17 Oct 2026.
Walk forward tests 66.7% of the sessions out of sample

The count is of Nifty trading sessions in the school's files, from 1 Jul 2025 to 15 Sep 2026. The first training window of 100 sessions is never tested out of sample. Source: NSE end of day data (count of sessions), computed by RupeeCase. As of 15 Sep 2026.

### 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](/learn/path-19/module-19-6-backtesting-options).

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.

### 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.

The term this section turns on: Embargo

From the module glossary; every term is in the Learn glossary too. Source: Module 19.7, Walk forward and out of sample testing.

### 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](/learn/path-19/module-19-6-backtesting-options) 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.

### How do I read the result?

Three checks, in this order. First, the stitched test record, judged by the measures in [strategy metrics](/learn/path-19/module-19-2-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

1. 25 Nov 2025**Test 1**Fit on 1 Jul to 24 Nov 2025, then trade 25 Nov 2025 to 4 Feb 2026.

2. 5 Feb 2026**Test 2**Fit on 11 Sep 2025 to 4 Feb 2026, then trade 5 Feb to 22 Apr 2026.

3. 23 Apr 2026**Test 3**Fit on 25 Nov 2025 to 22 Apr 2026, then trade 23 Apr to 6 Jul 2026.

4. 7 Jul 2026**Test 4**Fit on 5 Feb to 6 Jul 2026, then trade 7 Jul to 15 Sep 2026.

A rolling fit of 100 sessions and a test of 50 sessions, moved forward by 50 sessions each time. Sessions are NSE trading days, so the dates skip weekends and holidays. No embargo gap is cut here, to keep the count simple. Source: NSE end of day data, computed by RupeeCase. As of 15 Sep 2026.
Watch in the terminal: how often does the strategy trade? A short tutorial on sample data.

### 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.

### 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.

## 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

India VIX daily close. The marks show where each test window begins. The rule fitted before a window is tested on the volatility that follows it. Source: NSE end of day data, computed by RupeeCase. As of 15 Sep 2026.

| 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

Made up numbers, not market data, to show the arithmetic. The fit bar is the score on the training window and the test bar is the score on the window after it. Source: RupeeCase arithmetic, no market data. As of 17 Oct 2026.
Read 3 more paragraphs, 154 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 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. 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 lets only registered advisers, research analysts and empanelled algo providers make performance claims, verified by a PaRRVA. [Monte Carlo and bootstrap](/learn/path-19/module-19-8-monte-carlo-and-bootstrap) asks how much of the result could be luck.

## Key takeaways

* A test part is out of sample only until a result changes the rule.
* Walk forward repeats fit, freeze and test along the calendar.
* Four folds from the files test two thirds of the data.
* Cut an embargo gap as long as the holding period or feature window.
* A best parameter that jumps between folds is a sign of fitting noise.
* Ten trades a fold cannot carry a verdict by itself.

Watch in the terminal: which numbers am I looking at? A short tutorial on sample data.
**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](https://www.sebi.gov.in/reports-and-statistics/research/aug-2026/study-profitability-of-individual-traders-in-the-equity-derivatives-segment-fy25-fy26-_103835.html)

What does Walk forward and out of sample testing cover?Fit on one stretch, trade the next, slide forward. Four test windows from India's data show what each fold meets. It works through The idea, plainly, Worked example: four folds of a made up rule, The common mistake, Key takeaways. It is module 19.7 of Path 19, Algo, HFT and Backtesting, about 10 minutes of reading, free.

  AF&O on RupeeCase

## Hedging only, in development
F&O at RupeeCase will do one job: protect a portfolio you already own, by a rule published before it runs. No speculation, no naked option selling, no leveraged bets. It is not available yet.

  [How hedging will work](/hedging)[Sign up for RupeeCase](https://invest.rupeecase.com/signup)

  [No hedgeFalls with the marketWith a putA floor, for a premiumIllustration with made up numbers, not a product and not a recommendation.](/hedging)

QQuick check

## 10 questions, 7 to pass.
Each attempt draws 10 of the 15 questions in this module's bank, and a retake draws a fresh set. A pass gives this module's Certificate of Completion. Your result stays on this device and counts towards the Path 19 certificate.

7 of 10 correct passes module 19.7

Every answer is explained when you check; a retake is always free. Source: RupeeCase Learn quiz rules (70% to pass).

  Passed

###

  Certificate ID

Download PNGPrint or save as PDF[Check the ID](/learn/certificates/verify)
Self paced and unproctored. A record of completing free education by RupeeCase; not a NISM certificate and not endorsed by NISM, NSE, BSE or SEBI. It qualifies no one to deal, advise or publish research.

CCheck yourself

## Path 19 so far.
Your quick check results on this device, stop by stop.

Stop 7 of 16 on Path 19

Algo, HFT and Backtesting: every live stop, this module ringed. Source: RupeeCase Learn, Path 19.

1. [19.1What a backtest is, and five biases that ruin itNot yet](/learn/path-19/module-19-1-backtest-biases)
2. [19.2Strategy metrics: CAGR, Sharpe, Sortino, drawdown and expectancyNot yet](/learn/path-19/module-19-2-strategy-metrics)
3. [19.3HFT, MFT and LFT comparedNot yet](/learn/path-19/module-19-3-hft-mft-lft)
4. [19.4Colocation, latency and fairness: NSE's historyNot yet](/learn/path-19/module-19-4-colocation-and-latency)
5. [19.5Building a compliant retail algoNot yet](/learn/path-19/module-19-5-building-a-compliant-algo)
6. [19.6Backtesting options on Indian dataNot yet](/learn/path-19/module-19-6-backtesting-options)
7. [19.7Walk forward and out of sample testingNot yet](/learn/path-19/module-19-7-walk-forward-testing#quiz)
8. [19.8Monte Carlo and bootstrap of trade resultsNot yet](/learn/path-19/module-19-8-monte-carlo-and-bootstrap)
9. [19.9Microstructure models: spreads, informed trading and price impactNot yet](/learn/path-19/module-19-9-microstructure-models)
10. [19.10Market making: inventory and quotingNot yet](/learn/path-19/module-19-10-market-making)
11. [19.11Optimal execution and market impactNot yet](/learn/path-19/module-19-11-optimal-execution)
12. [19.12HFT economics and the latency raceNot yet](/learn/path-19/module-19-12-hft-economics)
13. [19.13Backtest overfitting: deflated Sharpe, PBO and multiple testingNot yet](/learn/path-19/module-19-13-backtest-overfitting)
14. [19.14Financial machine learning done carefullyNot yet](/learn/path-19/module-19-14-financial-machine-learning)
15. [19.15Expiry day market integrity: a SEBI interim order, FutEq limits and surveillanceNot yet](/learn/path-19/module-19-15-expiry-day-market-integrity)
16. [19.16Capstone: a research note on an Indian derivatives questionNot yet](/learn/path-19/module-19-16-capstone-research-note)
17. [TPath test, 30 questionsNot yet](/learn/path-19/module-19-16-capstone-research-note#pathTestSection)

Path 19 in reading time: 172 minutes over 16 modules

Minutes of reading per module, this one in amber. Source: RupeeCase Learn, Path 19.

    Explore next

## Put the module to work.

* [ToolOption payoff builderLegs on a dated Nifty chain, breakevens and charges](/learn/tools/payoff-builder)
* [Free module 19.1What a backtest is, and five biases that ruin it9 min read](/learn/path-19/module-19-1-backtest-biases)
* [Free module 19.2Strategy metrics: CAGR, Sharpe, Sortino, drawdown and expectancy9 min read](/learn/path-19/module-19-2-strategy-metrics)
* [Free module 19.6Backtesting options on Indian data11 min read](/learn/path-19/module-19-6-backtesting-options)
* [Free module 19.8Monte Carlo and bootstrap of trade results10 min read](/learn/path-19/module-19-8-monte-carlo-and-bootstrap)
* [Free module 19.13Backtest overfitting: deflated Sharpe, PBO and multiple testing11 min read](/learn/path-19/module-19-13-backtest-overfitting)

      Community

## Join my WhatsApp group.

      Scan the code, fillFill one short form, and join my WhatsApp group. Slides, sources, factsheets and the rebalance logs live there, and members join a daily Google Meet with me.

      New to RupeeCase? [Getting started](/getting-started) [See the terminal](/terminal)

        [Sign up for RupeeCase](https://invest.rupeecase.com/signup)
        [Join the WhatsApp group](https://forms.gle/C6HMtM1Z2GfeocQV7)

      [One form, one group](https://forms.gle/C6HMtM1Z2GfeocQV7)Scan with your phone camera

SSources

## Go to the source.
4 sources, NSE the most cited

The publisher of each source listed below. Source: Module 19.7 source list.
1. [NSE, derivatives reports and daily end of day files](https://www.nseindia.com/all-reports-derivatives) NSE
2. [NSE, equity derivatives contract specifications (expiry cycle and lot sizes by contract)](https://www.nseindia.com/static/products-services/equity-derivatives-contract-specifications) NSE
3. [SEBI, circular of 3 August 2026, enrolment with PaRRVA for verified past performance](https://www.sebi.gov.in/legal/circulars/aug-2026/extension-of-timeline-for-enrolment-with-parrva-as-specified-in-sebi-circular-no-ho-38-14-4-2026-mirsd-pod-i-10557-2026-dated-april-29-2026_103314.html) SEBI
4. Pardo, R., The Evaluation and Optimization of Trading Strategies, 2nd ed., Wiley, 2008 (walk forward analysis) Book

GTerms

## 4 terms from this module.
Out of sampleData a rule has not seen while being built. It stays out of sample only until a result on it changes the rule.
Walk forward testingFitting a rule on a training window, trading the next window with the parameters frozen, then sliding forward and repeating. The test windows join into one record.
EmbargoA gap between a training and a test window, at least as long as the holding period or the feature window, so no data leaks across the boundary.
Walk forward efficiencyThe mean test result divided by the mean fit result. A value near zero says the fit was mostly noise.
[All 230 terms in the glossary](/learn/glossary)

[Question people askWhat is walk forward testing?A short answer with a dated chart](/learn/questions/what-is-walk-forward-testing)[Related module19.1 What a backtest is, and five biases that ruin it9 min, Intermediate](/learn/path-19/module-19-1-backtest-biases)[Related module19.2 Strategy metrics: CAGR, Sharpe, Sortino, drawdown and expectancy9 min, Intermediate](/learn/path-19/module-19-2-strategy-metrics)[Pillar guideDerivatives and Quant115 modules across paths 12 to 19](/learn/derivatives)

Education only, not investment advice, a research report or a recommendation to buy, sell or hold any security. RupeeCase (QC Alpha Technologies Pvt Ltd) is not registered with SEBI as an investment adviser or research analyst. Contracts and prices shown are for illustration only, come from NSE end of day files at least 30 days old, and are not recommendatory. Derivatives trading carries a high risk of loss.
