Walk-forward analysis, explained properly

You optimised the strategy on 2016 to 2022 and tested it on 2023. It passed. That is one test, of one parameter set, on one year. Walk-forward analysis is what you do when you want to know whether it would have passed the other years too.

A single train/test split answers a narrow question: did the parameters I chose on the early data work on the later data? Useful, but it has two weaknesses. The test period is one draw — one year might have suited the strategy by chance — and the parameters were chosen once and never had to be chosen again. In live trading you will re-tune. The question that matters is whether re-tuning works.

Walk-forward analysis asks that question directly. Robert Pardo's The Evaluation and Optimization of Trading Strategies (2008) is the standard reference, and the idea has not needed improving since.

How it works

  1. Take a window of history — say three years — and optimise the strategy's parameters on it. This is the in-sample window.
  2. Apply those parameters, unchanged, to the next stretch — say six months. This is the out-of-sample window. Record the results.
  3. Slide both windows forward by six months. Re-optimise on the new in-sample window. Test on the new out-of-sample window. Record.
  4. Repeat until you run out of history.
  5. Stitch every out-of-sample window together, in order, into one equity curve. That curve is your result. The in-sample results are thrown away.

The stitched curve is made entirely of periods the strategy did not tune on, using parameters chosen the way you would actually choose them live: from the recent past, updated periodically. It is the closest thing to a rehearsal of real trading that history allows.

Anchored versus rolling windows

There are two ways to slide the in-sample window, and they encode different beliefs about the market.

Two window schemes
Anchored (expanding)Rolling (sliding)
In-sample startFixed at the beginning of historyMoves forward with the window
In-sample sizeGrows with each stepConstant
AssumesOld data stays relevant; more data is always betterRecent data is more relevant; old regimes should be forgotten
StrengthLarger samples, more stable parametersAdapts to regime change
WeaknessSlow to adapt; can be anchored to a regime that endedSmaller samples; parameters can jump between windows
SuitsSlow strategies on long historiesFaster strategies; markets that change character

Neither is right. Run both. If the strategy only works under one scheme, that is a finding — it tells you the strategy depends on either remembering or forgetting old data, and you should know which.

Sizing the windows: count trades, not months

The usual advice gives a ratio — a few years in, a few months out — but calendar time is the wrong unit. What the optimiser needs is enough trades to constrain the parameters, and what the test needs is enough trades to produce a number with a tolerable error bar. Size both windows in trades:

For a strategy that trades twice a week on daily bars, that might mean three years in and six months out. For one that trades ten times a day, weeks and days. The ratio falls out of the trade count; it is not an input.

Reading the stitched curve

The out-of-sample curve will be worse than the in-sample curves, always, because the in-sample results were selected and the out-of-sample ones were not. The question is how much worse, and in what way. Look for:

Walk-forward efficiency

Pardo's metric: annualised out-of-sample return divided by annualised in-sample return. If the strategy makes 30% a year in sample and 15% out of sample, efficiency is 50%. It is a compact way to express how much of the optimised result survived contact with unseen data.

You will see thresholds quoted for it — "above 50% is good". Treat those as folklore. The right efficiency depends on how much the optimiser had to choose from: a strategy with two parameters should retain most of its result, and one with twelve should lose a lot of it even when it is real. Use efficiency to compare versions of the same strategy against each other, not against a number someone else picked.

The trap: overfitting the walk-forward

Walk-forward analysis has parameters of its own — window sizes, step size, anchored or rolling, the optimisation target — and every one of them can be tuned. If you run fifteen walk-forward configurations and report the one with the best stitched curve, you have done to the walk-forward exactly what the walk-forward was supposed to stop you doing to the strategy.

The honest description of that result is "the best of fifteen", and it needs the same discount as any other best-of-N. Three defences:

  1. Choose the walk-forward configuration before you see any results, from the trade-count arithmetic above, and do not change it.
  2. Count every configuration you tried, and treat the count as part of the result.
  3. Keep a final stretch of history that no walk-forward configuration ever touched, and open it once. The out-of-sample guide covers the sealed holdout and the permutation test that go with it.

A workable procedure

  1. Fix the strategy's rules and the list of parameters to optimise.
  2. Size the in-sample and out-of-sample windows in trades, and set the gap to the label horizon. Write these down.
  3. Run rolling and anchored. Stitch each.
  4. Check consistency, parameter stability, character and recency.
  5. Compute efficiency and compare it only to earlier versions of the same strategy.
  6. If it holds, open the sealed holdout. Once.

How Wise Apple runs walk-forward

Walk-forward is the default evaluation in Wise Apple rather than an advanced option. The Walk-Forward Window setting rolls the chronological train/test split forward, Embargo Bars sets the gap between windows, and the report grades each out-of-sample window separately before stitching them, so consistency across windows is visible without exporting anything. Models are retrained per window on your own machine — which is the reason a ten-step walk-forward with a boosted-tree ensemble is something you can run over lunch rather than something you queue for. It does not choose the window sizes for you. That is the part you should write down first.

Questions traders ask about walk-forward analysis

What is walk-forward analysis in trading?

A validation method that optimises a strategy on one window of history, tests the result on the following window, then slides both windows forward and repeats. The out-of-sample windows are stitched into a single equity curve. It tests whether your method of choosing parameters keeps working over time, rather than whether one parameter set got lucky.

Should I use anchored or rolling walk-forward?

Run both. Anchored windows grow from a fixed start and assume old data stays relevant; rolling windows keep a constant size and assume recent data matters more. If the strategy only works under one scheme, that tells you it depends on either remembering or forgetting old regimes, which is worth knowing before you trade it.

What is a good walk-forward efficiency?

There is no universal threshold. Efficiency — out-of-sample return divided by in-sample return — depends on how many parameters the optimiser had to choose from; a strategy with many parameters will lose more of its in-sample result even when it is genuine. Use it to compare versions of the same strategy, not to pass or fail against a quoted number.

Can you still overfit with walk-forward analysis?

Yes. Window sizes, step size, anchoring and the optimisation target are all parameters, and choosing the configuration that produces the best stitched curve is overfitting one level up. Fix the configuration from trade-count arithmetic before you see results, count the configurations you tried, and keep a sealed holdout that no walk-forward run touched.

What is the difference between walk-forward analysis and a simple out-of-sample test?

A simple out-of-sample test optimises once and tests once, on one later period. Walk-forward repeats that many times: optimise on a window, test on the next, slide forward, and stitch the tested periods into one out-of-sample curve. It answers not just whether the strategy worked after the fit but whether the fitting procedure keeps working as the market moves, which a single split cannot tell you.