What is walk-forward analysis
Walk-forward analysis is a way to test a trading strategy: you optimise its settings on one stretch of past data, test those settings on the next stretch the optimiser never saw, then move both windows forward and repeat.
You will also see it called walk-forward testing or walk-forward optimization. Its purpose is to check whether a strategy still works on data it was not tuned on, rather than only on the history it was fitted to.
Ready to try it on a real or demo account?
Partner link · trading carries a high risk of loss
Formal definition
Walk-forward analysis is a sequence of paired segments taken in time order:
- In-sample (IS) window: the data used to optimise the strategy's parameters.
- Out-of-sample (OOS) window: the period that comes right after the IS window. The parameters chosen in-sample are applied to it unchanged.
After each pair, both windows shift forward, usually by the length of the OOS window. The OOS segments are then joined into one out-of-sample equity curve. That joined curve, not the in-sample result, is the estimate of how the strategy might have behaved.
There are two common variants:
- Rolling: the IS window keeps a fixed length and slides forward, so old data drops out.
- Anchored: the IS window always starts at the same date and grows longer with each step.
Worked example (hypothetical)
A trader tests a moving-average crossover on EUR/USD. The parameters are the lengths of the fast and slow averages.
- Take the earliest block of history as the IS window. Run an optimisation and pick the parameter pair with the best result.
- Apply that pair, without changes, to the following shorter block. This is the OOS window. Record the trades.
- Shift both windows forward by the length of the OOS block. Optimise again on the new IS window and test on the new OOS window.
- Repeat until the data runs out. Then join all the OOS results.
Suppose the in-sample results look strong but the joined out-of-sample curve is flat or falling. That usually points to overfitting: the settings matched past noise rather than a pattern that repeats. Some testers summarise this gap as walk-forward efficiency, which compares out-of-sample performance with in-sample performance.
Where you see the term
- MetaTrader 5 Strategy Tester has a forward testing option. It splits the chosen period into an optimisation part and a forward part. This is a single split, so a full walk-forward run means repeating it with shifted dates, by hand or with a script. See MetaTrader 5.
- Strategy reports and research papers often show separate IS and OOS statistics, or a stitched OOS equity curve.
- Algorithmic and API trading tools often include walk-forward modules.
Edge cases and limits
- Repeated reruns: if you change the method until the OOS result looks good, the OOS data effectively becomes in-sample.
- Too few trades per window: the results become mostly noise.
- Regime changes: a strategy can pass every window and still fail when market behaviour shifts. See fat tails and tail risk.
- Costs: tests that leave out spreads, commissions and swaps overstate results.
- Indicator warm-up: indicators need earlier bars to calculate. Taking them from the wrong window can leak future information into the test.
A good walk-forward result does not predict future profit. Leveraged forex and CFD trading can lose money fast. See risk management.
Related terms
Trading strategies · Technical analysis · Equity curve · Correlation coefficient · Trading glossary
Frequent questions
What is the difference between backtesting and walk-forward testing?
A backtest usually optimises and measures on the same data. Walk-forward testing always measures on data that comes after the optimisation period and was not used in it.
Is walk-forward optimization the same as walk-forward analysis?
In practice, yes. Both names describe the repeated cycle of optimising on one window and testing on the next.
Rolling or anchored: which is used?
Both are used. Rolling windows adapt faster to recent behaviour. Anchored windows use more data but react more slowly.
Can I practise this without real money?
Yes. You can run tests in the platform's strategy tester and then watch the strategy forward on a demo account. Neither shows how live trading will turn out.
