Guide · Backtest

Walk-forward analysis: what it is and what it's for

Walk-forward analysis optimizes a strategy on one section of history to test it on the next, several times in a row. It shows whether the strategy's inputs hold up on data they haven't seen.

How it works

  • You split the history into sections.
  • You optimize on the first; you test on the second, which the strategy hasn't seen.
  • You move forward one window to repeat.
  • You join all the test periods together: that's the result that counts.

How it differs from a regular backtest

A single backtest uses the same years to tune and to measure. Walk-forward analysis keeps the two apart at every step.

Walk-forward vs out of sample

Setting aside an out of sample period is a single check. Walk-forward analysis repeats it many times, with windows that move forward. Overfitting.

Walk-forward or Monte Carlo

They answer different questions. The first looks at whether the inputs keep working over time; the second, how far the strategy could fall with the same trades in a different order. Monte Carlo in trading.

An example

Ten years of data. You optimize on 2015 and 2016; you test on 2017. Then you tune on 2016 and 2017 to measure on 2018. You carry on like this to the end.

If nearly all the test sections make money, the strategy doesn't depend on one particular period. When only one works, the rest was curve fitting.

What it doesn't guarantee

Passing a walk-forward test doesn't ensure it will work live. Costs, slippage or a new market are left out.

The missing test is trading. Backtest or forward test.

The terms you'll come across

  • In sample: the section where you optimize.
  • Out of sample: the next one, held out for testing.
  • Anchored window: the start doesn't move; each step adds data.
  • Rolling window: it moves forward as a whole, leaving the oldest years behind.
  • Walk-Forward Matrix: in StrategyQuant X, the same test repeated with several window sizes.

How many sections, what size

Each test period needs enough trades to say something: 30 at the very least. A strategy that trades twice a month calls for windows longer than a year.

With very few steps, a single good section decides the result.

Common mistakes

  • Windows so short that each section has ten trades.
  • Repeating the process with different periods until it comes out right.
  • Taking the best of many configurations as a passed test.

Frequently asked questions

What is walk-forward analysis in trading?

Walk-forward analysis is a test that optimizes a strategy on one section of history and checks it on the next, several times in a row. It measures whether the strategy's inputs hold up on data they haven't seen.

Walk-forward or backtest: which should I use?

They aren't mutually exclusive. A backtest tells you how a strategy would have done with fixed inputs; walk-forward analysis, whether those settings keep working as time moves on.

What's the difference between walk-forward and Monte Carlo?

Walk-forward analysis tests the inputs on new periods. Monte Carlo reshuffles the same trades to see how far the strategy could fall.

Put your robots in orbit.

Try it free

Sign up in a minute, no card required.