Walk forward testing, explained with a real test

Walk forward testing means: pick a strategy's settings using only past data (say 3 years), test those settings on the next year it has never seen, then move the window forward a year and repeat. Joining the test years gives an honest record. In our 12-year test on SPY, the best moving-average settings made 12.3% a year on the data they were picked from but only 6.0% a year on the following unseen years - against 12.5% for simply holding.

Checked 5 November 2026 · sources below

Step by step

  1. Split the data. Choose an in-sample window (here 3 years) for picking settings and an out-of-sample window (here the next 1 year) for testing.
  2. Optimise in-sample only. Try your settings grid on the in-sample years and keep the best by one fixed measure, chosen before you look.
  3. Test on the next window. Run those exact settings on the out-of-sample year. Do not change anything after seeing it.
  4. Roll forward. Move both windows forward by one test period and repeat until the data runs out.
  5. Judge the joined test years. Only the joined out-of-sample results count. Compare them with the in-sample results and with buy-and-hold after costs.

Our walk forward on SPY (daily prices, 2011-2025): moving-average crossover, 3-year optimise, 1-year test, 0.05% cost per switch

Test yearBest settings (fast/slow days)In-sample, % a yearNext year (unseen), %Buy and hold, %
201445/15014.611.311.3
201520/17517.1-9.0-0.8
201650/12513.3-0.39.6
201725/2255.619.419.4
201825/2258.15.2-6.3
201925/22511.215.128.8
202025/20013.4-3.616.2
202130/5011.218.827.0
20225/17520.1-20.9-19.5
20235/2008.19.924.3
202450/25013.223.323.3
202550/25012.12.616.4

What our test shows

The settings that looked best kept changing (from 45/150 to 5/200 to 50/250), and their in-sample return of about 12.3% a year roughly halved on unseen data. The strategy beat buy-and-hold in only 1 of 12 test years (2018). That gap between in-sample and out-of-sample is the overfitting a normal backtest hides. Prices are Yahoo daily closes without dividends, for both the strategy and buy-and-hold.

The rolling windows, drawn

RoundPick settings onTest on (unseen)
12011-20132014
22012-20142015
32013-20152016
.........
122022-20242025

Each test year is used once and never for picking. Limits of our example: one market, one simple strategy family and one window length; a different strategy or market can behave differently, which is why you run the test on your own system.

A 10-minute spreadsheet version

  1. Put dates and closing prices in two columns.
  2. Add columns for the strategy's daily result with each setting you want to try.
  3. For each year, find the setting with the best total over the previous three years (a MAX over a filtered range).
  4. Copy only that setting's result for the year into a 'walk forward' column.
  5. Compare the walk forward column with the in-sample bests and with buy-and-hold.

Common mistakes

Questions

What is the difference between walk forward testing and backtesting?
A plain backtest picks settings and measures them on the same data. Walk forward picks settings on past data and measures them only on later data they never saw.
What is a good walk forward efficiency?
Out-of-sample return divided by in-sample return; our SPY test was about 0.49 (6.0 / 12.3). Many practitioners look for well above 0.5, but there is no official bar.
How long should the in-sample and out-of-sample windows be?
Long enough for many trades in each. A common start is 3-4 years in, 1 year out on daily data; check the trade count in each window.
Is walk forward testing the same as forward testing?
No. Forward testing usually means paper trading live. Walk forward is done on historical data.

Sources

Check your backtest for luck

Upload your trade list to Truth Test and see whether the result could be luck - free.

Check your backtest for luck