Test Your Strategy

Home / Blog / Walk-forward analysis

Walk-forward analysis explained

An optimised backtest tells you which settings would have worked best on data you already had. Walk-forward analysis asks the question that actually matters: if you had picked settings that way at the time, would they have kept working on the months that came next?

The problem walk-forward analysis solves

Optimisation always finds something. Give it enough parameter combinations and it will find a setting that made money over any stretch of history, including pure noise. The result is a backtest that is accurate about the past and says nothing about the future — the definition of curve fitting.

The fix is to separate the data used to choose parameters from the data used to judge them. A single split does part of the job. Walk-forward analysis repeats that split many times as it moves through history, so the verdict rests on many unseen periods instead of one.

How it works, step by step

  1. Pick an in-sample window — say two years of data.
  2. Optimise the strategy's parameters on that window only.
  3. Take the chosen settings forward onto the next, untouched window — say the following six months. Record the results without changing anything. This is the out-of-sample test.
  4. Slide both windows forward by six months and repeat.
  5. Stitch together every out-of-sample period into one equity curve.

That stitched curve is the closest thing a backtest can give you to a live track record: every trade in it was taken with settings chosen without knowledge of that period.

Rolling versus anchored windows

RollingAnchored
In-sample windowFixed length, slides forwardAlways starts at the beginning, grows each step
Adapts to new conditionsFaster — old data drops outSlower — old data keeps its weight
Parameter stabilitySettings can jump between stepsSettings tend to be steadier
SuitsStrategies that genuinely need recalibratingStrategies meant to work on fixed rules

Neither is "correct". Choose the one that matches how you would actually run the strategy live — if you would never re-optimise in practice, an anchored test or a single long out-of-sample period is the more honest check.

Reading the results

Walk-forward efficiency

The most common summary figure compares out-of-sample performance with in-sample performance, both annualised. If the optimised periods made 30% a year and the forward periods made 15%, the efficiency is 50%. Some decay is normal and expected — the in-sample figure is inflated by the selection. A widely used rule of thumb treats efficiency of around half or better as encouraging and figures near zero or negative as a sign the optimisation was mostly fitting noise.

How settings move between steps

Look at which parameters the optimiser picked in each window. If the best moving-average length is 20, then 22, then 19, the strategy has a stable region. If it lurches from 12 to 85 to 40, the optimiser is chasing noise, whatever the efficiency figure says.

How many forward windows were profitable

Seven profitable windows out of ten tells a different story from one enormous window and nine flat ones. An edge should show up repeatedly, not once.

The mistakes that quietly defeat it

  • Re-running until it passes. If you change the strategy, the window lengths or the optimisation target every time walk-forward disappoints, you have turned the out-of-sample data into in-sample data. The test only works if you accept its verdict.
  • Forward windows that are too short. A one-month window with six trades in it can't confirm or reject anything. Each forward window needs enough trades to be read on its own — see how many trades a backtest needs.
  • Optimising for the wrong thing. Maximising net profit rewards settings that took one lucky trade. Targets that penalise drawdown or reward consistency usually generalise better.
  • Leaving costs out. Walk-forward on a cost-free backtest only proves that a cost-free strategy would have worked.

Doing it in MetaTrader 5 and TradingView

MetaTrader 5's Strategy Tester has a built-in forward option: you choose what fraction of the date range is held back, the optimiser runs on the rest, and the best passes are re-run on the held-back period. That is a single split rather than a full rolling walk-forward, but it is a useful first check. A full walk-forward means scripting the repeated windows yourself or using external tooling.

TradingView has no native walk-forward feature, so it is done by hand: optimise on one date range, then lock the inputs and test the following range. It is laborious beyond a few windows, which is why serious walk-forward work usually moves to Python or MQL5.

Walk-forward tells you whether a strategy survived unseen data. It does not tell you how bad things could get with the same trades in a less lucky order — that is the job of Monte Carlo simulation.

Want a walk-forward test on your strategy?

Walk-forward validation is part of our backtest-and-automation package, run on cost-adjusted data.

WhatsApp