Walk-forward testing

By Otto Research 3 min read Article 49 of 95

Walk-forward testing addresses a specific weakness of the ordinary backtest: that the strategy's parameters were chosen with knowledge of the whole period. It splits history into consecutive windows and, for each, chooses the parameters using only the data before the window, then tests them on the window itself. The process is repeated, rolling forward through the history, so that every result comes from parameters that could have been chosen at the time.

How it works

Take a ten-year history. Choose parameters on years one to three and test on year four. Choose again on years one to four, or two to four, and test on year five. Continue to the end. The stitched-together results from the test years are the walk-forward result. They include every parameter change the process would have made along the way, and none of the hindsight.

What it shows

Whether the strategy's edge survives the act of choosing its settings honestly. A strategy that is good only at one particular set of values, found with hindsight, falls apart under walk-forward, because the values chosen in advance keep missing. A strategy with a real and stable edge produces walk-forward results not far below the ordinary backtest, and its chosen parameters stay in a narrow range from window to window.

What it does not show

It does not remove the selection of the strategy itself, which was still chosen with hindsight. It does not model costs, fills or spread any better than the backtest it is built on. It does not tell you what the strategy will do in a market unlike any in the history. And it can be gamed, by trying many walk-forward configurations and reporting the best, which is overfitting one level up.

Worked example

A breakout strategy backtests at 22 per cent a year over ten years with parameters chosen on the full period. Walk-forward, choosing parameters each year on the prior three, it returns 9 per cent a year, with the chosen lookback swinging between 15 and 60 from year to year. The edge is mostly hindsight. A second strategy backtests at 14 per cent and walk-forwards at 11, with its parameters barely moving. The second strategy is the one with something real in it, although its headline number was smaller.

What this means when an EA is trading

A vendor who describes a walk-forward test, and shows the walk-forward result beside the ordinary backtest, is showing an awareness of overfitting that most do not have. The gap between the two figures is informative, and a small gap is a good sign. It is still a test on historical data with all the limits of one, and it is still not a live record. Read it as a reason to take the strategy seriously enough to look at the forward test.

From theory to live

See it put to work.

The concepts on these pages are what Otto is built on. Watch it trade them live, on real accounts.