Register
Learn guide

Evaluate Strategies with Walk-Forward Testing

Walk-forward testing checks whether a strategy's settings still work on data they were not chosen on. You optimise the settings on one period, test them on the period that follows, then roll both windows forward and repeat. It is the most direct way to find out whether a good backtest comes from rules that hold up or from settings fitted to the past.

QuantPower Research · Updated 14 Nov 2026 · 17 min read

A normal backtest picks the best settings using all the data, so it always looks better than live trading will. Walk-forward testing only ever judges settings on data that came after they were chosen, as live trading does. The result is usually a smaller number than the backtest, and that smaller number is the honest one. This guide explains how the method works, how to read its result, how to choose the windows, how Indian rule changes since 2024 affect it, and how to run it with QuantPower's backtests.

What walk-forward testing does

PartWhat it means
In-sample windowThe period used to choose the settings, such as the stop loss or the entry time
Out-of-sample windowThe period that follows, used only to judge the chosen settings
RollMove both windows forward and repeat
Walk-forward resultThe out-of-sample periods joined end to end
Walk-forward efficiencyAverage out-of-sample result divided by average in-sample result
Rolling windowAn in-sample window of fixed length that moves forward
Anchored windowAn in-sample window that starts on the same date and grows
What it catchesSettings that fitted the noise of one period and do not carry over
What it cannot catchA future market unlike anything in the data

A short history of walk-forward testing

Traders have always known that a rule fitted to the past looks better than it trades. The problem became sharper when computers made it cheap to test thousands of settings. In the 1980s, commodity trading advisers in the United States began running optimisation software over years of futures prices, and many found that the best setting of one year was rarely the best of the next.

Robert Pardo described walk-forward analysis as a method in 1992, in *Design, Testing and Optimization of Trading Systems*, and expanded it in 2008.1 His point was simple: the only fair test of an optimised setting is on data the optimisation never saw, and the fairest version repeats that test across the whole history.

Academic work followed. In 2000 Halbert White published a test for data snooping, the error of reusing the same data to search for rules until one looks good.2 In 2014 and 2016 David Bailey, Marcos López de Prado and colleagues showed how quickly the chance of a false result grows with the number of settings tried, and proposed ways to measure it.3 Campbell Harvey and Yan Liu argued in 2015 that a strategy's reported performance should be cut back according to how many versions were tested before it was chosen.4

In India the method matters more than usual because the market's rules have changed several times in a short period. SEBI cut weekly index expiries to one per exchange from 20 November 2024.5 The NSE moved its expiries to Tuesday from 1 September 2025. Nifty's lot size became 65 from 31 December 2025, and the securities transaction tax on futures and options rose from 1 April 2026.6 A setting chosen on 2023 data was chosen on a different market, and walk-forward testing shows whether it survived the change.

Why a single backtest is not enough

When you try many settings on the same data and keep the best, part of the result is luck. The more settings you try, the more likely the winner simply fitted the noise in that period. This is the problem that avoiding overfitting is about, and it is the main reason strategies that backtest well disappoint when they go live.

The size of the effect is easy to underestimate. Take a strategy that has no edge at all: on average each trade makes nothing, with a spread of 40 Nifty points either way. Test it on 60 trades with different settings, and keep the setting with the best average. A simulation of that process gives:

Settings triedAverage trade of the best setting, with no real edge
1about 0 points
5about +6 points
20about +10 points
50about +12 points
200about +14 points

Fourteen points a trade is ₹910 a lot on Nifty, before costs. A trader who tested 200 settings would see that figure in the backtest and believe it. None of it is real. Walk-forward testing exposes it, because the best setting of one window does no better than chance in the next.

Walk-forward testing separates the two jobs:

  • In-sample period: the data used to choose the settings.
  • Out-of-sample period: the data used to judge them, which the optimisation never saw.

How walk-forward testing works, step by step

  1. Fix the rules that will not change. Decide what the strategy is: the instrument, the entry logic, the exits and the costs. Only the settings you want to choose are left open, such as a stop loss of 20% to 40%.
  2. Choose the windows. For example, 12 months to optimise and the following 3 months to test.
  3. Optimise on the first in-sample window. Run the backtest with each candidate setting and keep the best by a measure chosen in advance, such as net result per unit of drawdown.
  4. Test on the next out-of-sample window. Run the chosen setting, unchanged, on the following 3 months and record the result.
  5. Roll forward. Move both windows on by 3 months and repeat.
  6. Join the test periods. The out-of-sample results, joined end to end, are your walk-forward result.
  7. Read it as a whole. Look at the efficiency, the stability of the chosen settings, the losing windows and the drawdown, not only the total.

The measure in step 3 matters. Choosing the setting with the highest net profit tends to pick the riskiest one, because larger risks produce larger results in either direction. A measure that divides the result by the drawdown, or by the worst month, picks settings that are more likely to repeat.

Rolling and anchored windows

TypeIn-sample windowSuits
RollingFixed length that moves forward, such as the last 12 monthsMarkets whose behaviour changes, such as index options after rule changes
AnchoredStarts at the same date and grows each stepStrategies that need as much history as possible

Rolling windows adapt faster. Anchored windows give more stable settings but react slowly when the market changes. For Indian index options after November 2024, a rolling window is usually the better choice, because data from before the rule changes describes a market that no longer exists in the same form.

A third choice is a rolling window with a gap: leave a few days between the in-sample and out-of-sample windows so that a trade open at the end of one window cannot leak into the next. Strategies that hold positions for days need this gap; intraday strategies that close every position by the end of the day do not.

A worked example: the stop loss of a Nifty short straddle

Five walk-forward windows of 12 months optimised and 3 months tested, with the chosen stop loss of each (illustration)

This hypothetical test chooses the stop loss for a Nifty weekly short straddle, between 20% and 40% of the premium collected on each leg, using 12-month in-sample windows and 3-month out-of-sample windows. The figures are average net Nifty points per expiry after costs, for illustration only.

WindowOptimise onTest onChosen stop lossIn-sample, points per expiryOut-of-sample, points per expiry
1Jan–Dec 2021Jan–Mar 202225%3120
2Apr 2021–Mar 2022Apr–Jun 202230%2815
3Jul 2021–Jun 2022Jul–Sep 202230%3018
4Oct 2021–Sep 2022Oct–Dec 202225%33−4
5Jan–Dec 2022Jan–Mar 202335%2717

The in-sample windows average 29.8 points per expiry, about ₹1,937 a lot. The out-of-sample windows average 13.2 points, about ₹858 a lot. Live trading would most likely look like the second figure, and even that comes from a market with weekly expiries that have since changed.

Walk-forward efficiency

Formula
Walk-forward efficiency = average out-of-sample result ÷ average in-sample result

In the example, 13.2 ÷ 29.8 gives an efficiency of about 44%. Many traders treat an efficiency above about 50% as a sign that the rules hold up on new data. A much lower figure suggests the optimisation is mostly fitting noise. An efficiency near zero, or negative, means the chosen settings did no better than chance on new data.

Efficiency is a ratio, so it can mislead when the in-sample result is small. A strategy that made 2 points in-sample and 1.5 points out-of-sample has 75% efficiency and no useful edge after costs. Read the ratio together with the out-of-sample figure itself.

Reading the result

Efficiency is one number. Four more checks tell you whether to trust it:

  • Stability of the chosen settings. If the best stop loss jumps between 20% and 40% from one window to the next, the strategy is sensitive to the setting. In the example it stays between 25% and 35%, which is reassuring.
  • Losing test windows. One losing quarter out of five, as in window 4, is normal. Several in a row are a warning.
  • Drawdown in the test periods, compared with what you can afford. The joined out-of-sample curve is the closest thing you have to a preview of live trading.
  • Number of trades. A window with eight trades says little. Weekly strategies need long windows to collect enough trades; intraday strategies collect them faster.

It also helps to look at the neighbours of the chosen setting. If 30% was chosen, how did 25% and 35% do in the same window? When the result falls off a cliff on either side, the chosen value sits on a narrow peak that is unlikely to hold. A broad plateau, where nearby settings all do reasonably, is a better sign.

Choosing window lengths

  • Enough trades. The in-sample window should contain enough trades for the result to mean something. Many traders aim for at least 30 to 50 trades in each window.
  • Test window size. The out-of-sample window is usually a quarter to a third of the in-sample length.
  • Rule breaks. For Indian index options, natural break points are 20 November 2024 (one weekly expiry per exchange), 1 September 2025 (NSE expiry on Tuesday), 31 December 2025 (Nifty lot 65) and 1 April 2026 (higher STT on futures and options).56 An in-sample window that spans a break mixes two markets.
  • Seasons and events. A 12-month window includes one Budget, a few RBI policy days and the results seasons. A 3-month window may include none, so a test window can look quiet or wild by chance.
Strategy holds positions forSuggested in-sampleSuggested out-of-sample
Minutes to a day (intraday)3 to 6 months1 month
One expiry week12 months3 months
Several weeks (positional)2 to 3 years6 months

These are starting points, not rules. Count the trades in each window and adjust.

The unseen-days check in QuantPower

QuantPower's option strategy backtest builds a simple version of this test into every run. It treats the first 70% of the trading days in the period as the days the strategy was built on, and the last 30% as unseen. The report compares the average result per day in the two parts and gives one of five verdicts:

VerdictWhat it means
Held up on unseen daysThe unseen days averaged at least half of what the built-on days averaged
Weaker on unseen daysThe unseen days were in profit but averaged less than half
Fell apart on unseen daysThe unseen days lost money on average
Lost money even in the period it was built onThe rules did not work even on the days they were fitted to
Too few days to judgeFewer than 20 built-on days or fewer than 10 unseen days

This is one split, not a full walk-forward. It is a quick first filter: if a strategy fails it, there is little point in a longer test. The page on backtesting describes the full report.

Running a full walk-forward in QuantPower

An option strategy backtest in QuantPower takes a start date and an end date, so you can run each window yourself8:

  1. Build the strategy with the setting you want to choose left as the only change between runs, for example the stop loss on each leg.
  2. For the first in-sample window, run one backtest for each candidate setting, with the same costs and slippage each time.
  3. Write down the best setting by your chosen measure, and the in-sample figure.
  4. Run that setting, unchanged, on the out-of-sample window and write down the result.
  5. Repeat for each window and join the out-of-sample figures.

Rule backtests on a single instrument read up to 2,000 of your broker's candles, from 5-minute to daily. For those, a practical check is to choose the setting on one candle size and test it on another: a rule chosen on 15-minute candles that also holds on hourly candles is less likely to be fitted to noise.

What it costs. A walk-forward with 5 windows and 5 candidate settings takes 25 in-sample runs and 5 out-of-sample runs, 30 backtests in all. The first 10 backtests each week are free and the rest cost 2 tokens each, so the whole test costs about 40 tokens (1 token = ₹1, GST extra) if done in one week. A run that fails costs nothing, and rerunning a test with only the slippage changed is free.

Keeping a record of the test

Write the test down as you go. A simple table with one row per window is enough: the in-sample dates, the candidate settings and their results, the chosen setting, the out-of-sample dates and the out-of-sample result. Note the costs and slippage used and the measure you chose on. The record does three jobs. It stops you from quietly rerunning a window until it looks better. It lets you repeat the test later with new data and compare. And it is the evidence you need when you explain, to yourself or to anyone else, why a strategy runs with the settings it has. Under India's rules for retail algos, where each strategy runs through a broker, a clear record of how it was tested is worth keeping for every algo you switch on.

A second example: choosing an entry time

Suppose you want to choose the entry time for a Nifty short straddle: 9:20, 9:45, 10:15 or 11:00. A single backtest over two years might show 10:15 as clearly best. A walk-forward with four 6-month in-sample windows and 3-month test windows might show:

WindowChosen timeIn-sample rank of 10:15Out-of-sample result
110:151stIn profit
29:452ndIn profit
310:151stSmall loss
411:003rdIn profit

The best time changes from window to window, but every chosen time is in the morning and three of four test windows are in profit. The reading is that a morning entry works on this data and the exact minute does not matter much. Picking 10:15 because the single backtest said so would have been false precision. This kind of result is common, and it is useful: it tells you which choices matter and which do not.

Walk-forward testing for different kinds of strategy

The method is the same for every strategy, but what it tends to reveal differs.

Option selling. Short straddles, strangles and iron condors usually show a smooth in-sample curve with occasional sharp losses. The setting most often fitted to noise is the stop loss: a stop that happens to sit just beyond the worst spikes of the in-sample period looks excellent and then fails on the next spike. Walk-forward testing shows whether the chosen stop holds across windows that contain different spikes. Watch the out-of-sample drawdown more than the average.

Option buying. Breakout and momentum strategies on bought options win rarely and lose often, so a short window may contain only a few large wins. The in-sample result can depend on two or three trades. Use longer windows, count the winning trades in each, and treat a window with fewer than five wins as inconclusive.

Trend following on futures. Moving-average and channel strategies have few settings and long holding periods. Walk-forward results for them often show a stable range of good settings, such as any fast average between 10 and 30, rather than one sharp best value. That stability is the most useful finding.

Mean reversion. Strategies that buy dips and sell rallies depend on the market staying in a range. Walk-forward windows that include a strong trend often show losses even with the best in-sample settings. That is not a fault of the test: it tells you the strategy needs a filter that switches it off in trends, or a smaller size.

Intraday rules with many settings. An intraday rule with an entry time, an exit time, a stop, a target and an indicator filter has thousands of combinations. Fix most of them from reasoning before the test, and optimise only one or two.

A checklist before you trust a walk-forward result

  1. The rules, the measure for choosing settings and the window lengths were decided before the test.
  2. Costs and slippage were included in every in-sample and out-of-sample run.
  3. Each window holds enough trades, and the out-of-sample windows together cover rising, falling and sideways markets.
  4. The chosen settings are stable from window to window, or sit on a broad plateau of reasonable results.
  5. The efficiency is reasonable and the out-of-sample figure itself clears costs with room to spare.
  6. The joined out-of-sample drawdown is one you could sit through with real money.
  7. No window spans a major rule change without that being taken into account.
  8. You did not go back and change the rules after seeing the out-of-sample results. If you did, the test needs fresh data.

A strategy that passes all eight is worth a forward test. One that fails two or more needs more work before any money goes into it.

Walk-forward and other checks compared

CheckWhat it doesStrengthWeakness
Single backtestTests settings on the data they were chosen onFastAlways optimistic
One split (in-sample, out-of-sample)Chooses on the first part, tests on the lastSimple, as in QuantPower's unseen-days checkOne test period can be lucky or unlucky
Walk-forwardRepeats the split across the historyMany test periods, close to how live trading worksNeeds enough data and more runs
Cross-validationTests on many slices, including earlier onesUses all the dataCan leak future information into past tests unless purged
Monte Carlo resamplingReshuffles trades to see the range of outcomesShows how bad a run of losses can getAssumes trades are independent
Forward testRuns the rules on live prices without real ordersMeets real fills and timingSlow: weeks of market time

They work best together. Walk-forward testing for the choice of settings, a Monte Carlo simulation for the range of drawdowns, and a forward test for execution.

Common mistakes

  • Changing the rules after seeing the test results. Each change uses up the out-of-sample data, which then stops being out of sample.
  • Optimising too many settings at once. Every extra setting multiplies the combinations tried and the chance of fitting noise.
  • Choosing the measure after the test. Decide in advance whether you are choosing on net result, result per drawdown or something else.
  • Ignoring costs. Include brokerage, STT and slippage in every window. A setting that trades more often looks better before costs and worse after them.
  • Leaking future data. A signal that uses information not yet available at the time of the trade inflates every window. See look ahead bias.
  • Mixing rule regimes. An in-sample window that spans November 2024 or September 2025 mixes markets with different expiries.
  • Too few trades per window. A result built on a handful of trades is noise, whatever the efficiency says.

Where walk-forward testing is going

Three changes are already visible. The first is scale: what took a desktop and a night now takes a browser and a few seconds, so traders test more ideas and need stronger guards against the data snooping that White described. The second is AI: assistants that write a strategy from a sentence can produce many variants quickly, and every variant tested on the same data adds to the chance of a false result. The third is regulation: since 1 April 2026, algos offered to retail traders in India run through brokers under exchange rules, with each strategy registered.7 A record of how a strategy's settings were chosen and tested is becoming part of explaining what an algo does.

After walk-forward testing

A walk-forward test is still a test on the past. Before going live:

  1. Run the strategy in a forward test for a few weeks to check fills and timing on live prices. A Forward test algo costs 100 tokens per 28 days.
  2. Compare the forward test with the walk-forward result for the same kind of market. A large gap points to fills, spreads or rules that behave differently live.
  3. Start live with the smallest size, with Smart Exit set for the account and a daily loss limit, which refuses new orders once the day's loss reaches it.

Start with 500 free tokens

Connect your broker, build a strategy and test it on paper before a single live order goes out.

Frequently asked questions

What is the difference between a backtest and a walk-forward test?

A backtest runs a strategy on past data, often with settings chosen on that same data. Walk-forward testing chooses the settings on one period and judges them only on the period that follows, repeated across the history.

How many walk-forward windows do I need?

Enough to cover different market conditions. Five or more out-of-sample windows across rising, falling and sideways markets is a reasonable minimum, each with enough trades to mean something.

What is a good walk-forward efficiency?

Many traders look for an efficiency above about 50%. The stability of the chosen settings, the out-of-sample figure itself and the drawdowns in the test windows matter as much as the single ratio.

Is walk-forward testing the same as forward testing?

No. Walk-forward testing uses historical data. A forward test runs the strategy on live prices as they happen, without real orders.

Does QuantPower do walk-forward testing automatically?

Every option strategy backtest includes an unseen-days check, which compares the first 70% of the period with the last 30%. A full walk-forward with several windows is run by choosing the dates of each backtest yourself.

Should I use data from before November 2024 for Indian index options?

You can, but treat it as a different market. Weekly expiries, lot sizes, expiry days and STT have all changed since then. A rolling in-sample window that starts after the change gives a cleaner test.

References

  1. Robert Pardo, *Design, Testing and Optimization of Trading Systems* (1992), and *The Evaluation and Optimization of Trading Strategies* (2008)
  2. Halbert White, "A Reality Check for Data Snooping", *Econometrica* 68(5), 2000
  3. David H. Bailey, Jonathan M. Borwein, Marcos López de Prado and Qiji Jim Zhu, "The Probability of Backtest Overfitting", *Journal of Computational Finance* (2016)
  4. Campbell R. Harvey and Yan Liu, "Backtesting", *Journal of Portfolio Management* 42(1), 2015
  5. SEBI, circular "Measures to strengthen Equity Index Derivatives framework for increased investor protection and market stability", 1 October 2024 (sebi.gov.in)
  6. NSE, circulars on the revision of expiry days (effective 1 September 2025) and of index derivative lot sizes (effective 31 December 2025); Union Budget 2026-27, STT on futures and options from 1 April 2026 (nseindia.com)
  7. SEBI, circular on safer participation of retail investors in algorithmic trading, 4 February 2025, in force for every broker from 1 April 2026 (sebi.gov.in)
  8. QuantPower: backtest engine, unseen-days check and token prices, from the app's code and price list, checked 12 November 2026
The examples on this page are hypothetical and for illustration only. Past and backtested results do not guarantee future results. Trading involves substantial risk.