Walk-Forward Testing
Fitting on one window and testing on the next, repeatedly. It is the closest a historical test can come to simulating how a strategy would actually have been run.
MadStockAlerts Research · Updated August 29, 2026
What to take away
- Parameters are fitted on a training window and tested on the following one.
- The window then rolls forward, producing a series of out-of-sample results.
- It simulates the sequence in which decisions would actually have been made.
- Repeatedly adjusting the method after seeing results contaminates the whole test.
- The out-of-sample degradation is itself the most useful output.
MAD Academy Training Video · 0:46
Testing on Data You Have Not Seen
Walk-forward optimisation repeatedly fits on one period and tests on the next, which is the closest a backtest gets to honest.
This lesson is part of a Stock Alerts + Tools plan.
The procedure
- 1Choose a training windowFor example the first three years of the data.
- 2Fit the parameters on itWhatever optimisation the method uses, performed only on that window.
- 3Test on the next windowA period the fitting never saw. Record the result.
- 4Roll both windows forwardAnd repeat, either rolling or expanding the training window.
- 5Assemble the out-of-sample resultsThe concatenated test periods are the performance estimate.
The result is a return series that was never used to fit anything, produced in the same chronological order in which the decisions would have been made. That ordering is what distinguishes it from a single holdout test.
- 1Fit on the training windowWhatever optimisation the method uses, on that window only
- 2Test on the next windowA period the fitting never saw. Record it
- 3Roll both forwardAnd repeat across the whole history
- 4Assemble the out-of-sample seriesWhich is the performance estimate
- 5Change nothing afterwardsAdjusting the method now contaminates every result
Why it is better than a single holdout
- It produces many out-of-sample periods rather than one, which is a larger sample of the thing being estimated.
- It covers multiple regimes, since the periods span different market conditions.
- It reflects that a real strategy would have been re-fitted periodically as data accumulated.
- It reveals whether the optimal parameters are stable over time, which a single fit cannot show.
The fourth item is frequently the most informative output. If the fitted parameters swing wildly from window to window, the optimisation is chasing noise, and that is visible from the parameter series regardless of what the returns look like.
The way it gets contaminated
Walk-forward testing is robust to overfitting within any window and entirely vulnerable to overfitting across the whole exercise. If the method is adjusted after seeing the out-of-sample results, those results are no longer out of sample.
- Changing the window lengths because a different choice produced better results.
- Adding a filter after observing which periods performed badly.
- Changing the universe or the rebalancing frequency in response to the output.
- Running the procedure repeatedly with variations and reporting the best.
Each of these is easy to do without noticing, because each feels like refinement rather than fitting. The only defence is recording every variation attempted, so that the count is known when the final result is interpreted.
What to expect from the output
The out-of-sample results will almost always be worse than the in-sample ones. That is not a failure of the method; it is the method reporting how much of the in-sample result was fitting.
| Observation | Reading |
|---|---|
| Out-of-sample close to in-sample | Unusual. Worth checking for contamination |
| Out-of-sample materially worse but still positive | The common and encouraging case |
| Out-of-sample near zero | The in-sample result was mostly fitting |
| Out-of-sample negative | The method is worse than nothing, which is a definitive result |
Even a well-conducted walk-forward test remains a historical exercise. It cannot establish that a regime will persist, and the strongest claim it supports is that a rule was not obviously fitted to the past it was built on.
Paper trading, and what it adds
After a walk-forward test, running a strategy forward on live data without capital is the only remaining test before committing money, and it addresses failures a historical test structurally cannot.
| What it catches | Why a backtest cannot |
|---|---|
| Data availability in real time | Historical data is complete; live data arrives late, revised, or not at all |
| Signal timing | A backtest computes signals instantly; in practice the data arrives on a schedule |
| Operational failures | Feeds break, and orders fail |
| Whether the rules can be followed | A backtest never hesitates |
The last row is the one that most often ends a strategy. A mechanical rule executed by a person is subject to every behavioural effect in the psychology pillar, and a period of following it without money at stake is the cheapest available test of whether it will be followed with money at stake.
What paper trading does not test is the effect of real fills, real impact and the emotional weight of real capital. It is a necessary step and not a sufficient one.