TradeAlmanac
Sign in

Walk-forward analysis: why a strategy is tested on data the optimiser has never seen

· 5 min · beginner

Automated material · TradeAlmanac editorial deskDraft prepared by a language model from our stored data; not reviewed by an editor.

145 views
Walk-forward analysis: why a strategy is tested on data the optimiser has never seen — Strategies

Walk-forward analysis is a procedure for testing a trading system in which parameters are fitted on one segment of history and the result is taken from the next segment, one that played no part in the fitting, window after window until the end of the sample. The point is not to produce an attractive equity curve but to separate a genuine pattern from curve-fitting: an ordinary backtest shows how the system would have looked had you known the best settings in advance, while walk-forward shows how it would have behaved had you not known them. The gap between those two pictures is the price of your optimisation.

What the procedure actually does

History is split into consecutive segments. On the first segment, the in-sample or training period, you run through parameter combinations and select a set according to a criterion declared in advance. That set is then frozen and applied to the next segment, the out-of-sample or test period, with no right to touch anything. Trades in the test period go into the final report. Then the window moves forward: the former test segment is added to the training data, the parameters are recalculated, and the system once again trades "blind" on a new stretch. The stitched-together sequence of all the test segments is what is called the walk-forward equity curve.

The key point of discipline is the order of the steps. Step 1: declare the parameter-selection criterion before you have seen any results. Step 2: run the search on the training data only. Step 3: apply the frozen parameters to the test window and never go back. The moment you see a poor test result and go off to change the selection rule, the test data stop being unseen, and the procedure turns into the same backtest, only with extra computation.

How this differs from a simple sample split

A one-off division of history into "training" and "testing" gives a single answer about a single period. Markets change regime: periods of broad trends, periods of compression, periods in which moves are driven by interest rates or the currency rather than by corporate news. A static split answers the question "did this work back then?". Walk-forward answers a more useful question: how often re-optimisation kept pace with changes of regime, and how quickly the settings went stale. If every new window demands radically different parameters, the system is not adaptive — it is simply chasing noise, and the test segments will show it.

It is also worth distinguishing walk-forward from sensitivity analysis: the latter asks what happens when a parameter shifts, the former what happens when time shifts. They are complementary tools, not substitutes for each other. The broader framework — testing a hypothesis with a rule — is covered in our piece on quantitative analysis.

Rolling window versus anchored window

A rolling window of fixed length forgets old history: useful if you believe that market microstructure and the mix of participants change, so the distant past no longer describes the present. An anchored, or expanding, window accumulates all available history: it is more robust to chance but slower to react to a break in regime. The choice between them is a substantive statement about the market, not a technical detail, and it is worth saying out loud: "I believe that data from before the 2022 trading suspension do not describe the current regime of the Russian equity market" is a hypothesis that the walk-forward procedure itself cannot test.

What counts as the result

Look not at the best run but at the distribution of runs. Useful questions: did the out-of-sample result stay positive in every window; how much worse is out-of-sample performance than in-sample; are the selected parameters stable from window to window; does the whole curve rest on a handful of exceptional trades. The last point matters most: a system whose total is made by a few episodes behaves unpredictably on new data, because what you tested was not a rule but a rare event.

Where the procedure still deceives you

First, history itself happens only once. However many windows you carve out, they come from a single realisation of the market and overlap in their data, so the out-of-sample results are not independent. Second, if you have tried many variants of the procedure itself — window lengths, re-optimisation frequency, selection criterion — you are curve-fitting again, just one level higher. The honest way out is to fix the design before the run and limit the number of free elements.

Third, data quality. Survivorship among securities, dividend adjustments recalculated after the fact, changes in index composition, delisting of depositary receipts — all of these leak knowledge of the future into the test. Check which list of instruments the result was calculated on: selecting by the market's current composition in stock quotes tilts the past in your favour. The same applies to event-driven logic: publication and payment dates must be taken as they actually occurred, not as is convenient — the events calendar is there for cross-checking.

Fourth, costs. Re-optimisation changes trading frequency, and the spread, commission and slippage usually eat up precisely the high-frequency configurations. If costs are modelled crudely, walk-forward tests arithmetic, not the strategy. This is a good moment to remember the limits of technical analysis: a validation procedure does not turn a weak signal into a strong one.

The platform does not store the history of other people's strategies or publish their walk-forward statistics, so you will have to run the test on your own data — here we describe only the method and its weak points. Definitions of the terms that appear in descriptions of such procedures are collected in the glossary.

How to read someone else's walk-forward

Ask about the things people are most willing to hide: how many parameters were searched and by what criterion; whether costs were included, and how; whether the list of instruments matches what was actually available on each date; whether the full sequence of windows is shown or only the successful ones. A report without these answers is not a test but a sales pitch. And one last thing: a procedure polished to perfection easily becomes an excuse never to start — a state that has a name of its own, analysis paralysis.

Share
Was this useful?
How this material was prepared

Draft prepared by a language model from our stored data; not reviewed by an editor.

Model: claude-opus-5

How we use language models

Similar articles