LEARN · EN · easyquanttrading.com

Walk-forward analysis: testing a strategy the way you would actually trade it

A single backtest answers one question: how did these exact rules do on this exact stretch of history? Walk-forward analysis answers a more useful one: if I had re-fitted the rules every so often, using only what was known at the time, would each following stretch have worked? The difference between those two questions is the difference between a description and a test.

The mechanic

Cut history into consecutive blocks. Train the strategy on block one, then run it forward on block two without changing anything. Slide the whole thing one block ahead: train on block two, test on block three. Repeat until you run out of data.

Every test segment is genuinely unseen at the moment the parameters were chosen, because the parameters were chosen before that segment existed. That is the entire point, and it is the only property that makes the result worth anything.

What it looks like when a strategy is fragile

A robust strategy produces a row of out-of-sample segments that are mostly positive, with a couple of flat or mildly negative ones. The magnitudes vary — they always do — but the sign is consistent enough that you would not have abandoned it in month two.

A fragile strategy looks different in a way that is easy to spot once you know to look for it: the in-sample segment is excellent and the out-of-sample segment that follows is poor, over and over. The strategy is not failing randomly. It is failing specifically on data it has not seen, which is the signature of memorisation.

PatternWhat it usually means
Train strong, test strong, consistentlyThe rules capture something that persists
Train strong, test weak, consistentlyThe rules were fitted to noise
Train strong, test wildly variableSample too small, or regime-dependent
Both weakNo edge at this timeframe and cost level

The pattern matters more than the average. Averages hide the failures you care about.

How many windows is enough

The honest answer is: enough that the result is not dominated by one segment. Three windows means one bad segment is a third of your evidence. Five to ten is a more reasonable starting point for a strategy with a few hundred trades overall.

There is a real tension here. More windows means shorter test segments, and short segments mean fewer trades, and few trades mean the segment's result is mostly noise. So you are trading one kind of uncertainty for another. The way out is to look at the trade count per segment and ignore any window that does not contain enough trades to be interpretable — usually anything under about thirty.

The trap: re-optimising every window

Walk-forward analysis is often implemented as 're-optimise the parameters on each training block, then apply them to the next block'. Done well, that is a genuine test of a process. Done carelessly, it is a machine for producing good-looking results, because you are still searching — just searching in a way that is harder to see.

If your walk-forward requires re-optimising to work at all, ask what that means. It means the strategy has no stable parameters, and that you are relying on the optimiser to keep finding the current regime. That can work, but it is a different claim from 'this strategy is robust', and it should be stated that way.

Reading the output without fooling yourself

  • Look at the sign pattern across windows before you look at any aggregate number.
  • Check the trade count in each test window; discard windows too small to mean anything.
  • Compare the average out-of-sample result to the average in-sample result. A large drop is not automatically fatal, but it is the number to explain.
  • Check whether the strategy survives if you remove its single best window. If one window carries everything, you have one observation, not ten.
  • Repeat the whole exercise on a different instrument. Real behaviour leaves a trace somewhere else.

Why we report it separately from the headline backtest

A walk-forward result and a full-sample backtest answer different questions, and averaging them into one number loses exactly the information that was worth having. That is why our strategy pages keep the checks separate and let you require the ones you care about.

Neither number is a forecast. Both are measurements of the past under different assumptions about what you knew when. The walk-forward one is simply closer to the situation you will actually be in.

FAQ

Is walk-forward the same as out-of-sample testing?
They are related but not identical. A single out-of-sample test holds back one period. Walk-forward analysis repeats the hold-out across many consecutive periods, which turns one result into a distribution and makes it much harder for a lucky stretch to carry the verdict.
How long should each window be?
Long enough that each test segment contains a meaningful number of trades — a few dozen at minimum — and long enough to include both a quiet and an active period if possible. That usually means months rather than days for daily strategies.
Can walk-forward results be overfitted too?
Yes. If you try many different window sizes and pick the one that looks best, you have fitted the window length. The defence is to decide the window structure before running it, and to treat the choice as part of the strategy rather than as a free parameter.

More guides

Not investment advice. Historical results do not guarantee future performance. EasyQuant is a research factory — you execute on accounts you control.