Walk-forward testing: how it works, step by step

By Oalgo · Last reviewed

Walk-forward testing tunes your settings on one slice of history, checks them on the next slice, and then moves forward and repeats. It shows whether settings hold up on prices they were not tuned on.

Diagram: six slices of past prices, from oldest to newest. In round 1 slices 1 to 3 are used to tune and slice 4 to check. In round 2 slices 2 to 4 tune and slice 5 checks. In round 3 slices 3 to 5 tune and slice 6 checks.Older pricesNewer prices123456Round 1TuneCheckRound 2TuneCheckRound 3TuneCheck
Each round moves one slice forward. The slices are an example.

How does walk-forward testing work?

#
  • Cut the past prices into equal slices, oldest to newest.
  • Tune your settings on the first few slices. This is the tuning window.
  • Run the tuned settings once on the next slice, the check slice, and change nothing.
  • Move both windows forward by one slice and repeat.
  • Put the reports of the check slices side by side. Those slices are the only prices the settings never saw.

What does a six-slice example look like?

#
RoundTune on slicesCheck on slice
11, 2 and 34
22, 3 and 45
33, 4 and 56

Three rounds give three check slices: 4, 5 and 6. Slice 4 is tuning data in round 2, and that is allowed, because the round 1 check is already done. Slices 1, 2 and 3 are never used to check.

How do you do it by hand in Oalgo?

#
  • Choose a date range and cut it into slices. Each backtest runs on the dates you pick, within the history your plan allows.
  • Backtest the tuning slices and change one setting at a time until you are happy.
  • Without changing anything, backtest the check slice. Write down the number of trades, the drawdown and the fees.
  • Repeat for the next round, then compare the check slices.

Oalgo also has a quick version for a finished run. The Risk view of the Analytics tab has a Did It Hold Up? card that cuts the run by time into the first 70% and the last 30% and shows both. It is one cut with no tuning inside it, so it is a check and not a full walk-forward.

What do you look for in the check slices?

#
  • Whether each check slice has enough trades to read. Slices with a handful of trades say little (see how many trades you need).
  • Whether the check slices look like the tuning slices. A large drop in every check slice is a warning of overfitting.
  • Whether the settings stay about the same from round to round. Settings that jump around suggest the fit is chance.

What can walk-forward testing not tell you?

#
  • It uses past prices only. A forward test is the only check on prices that did not exist when you tuned.
  • A check slice stops being a fresh check once you change settings after seeing it.
  • Each round is another try, and more tries make a chance fit easier to find.
  • It does not say what prices will do next.

Each check is a backtest on one slice, and the backtest report guide shows what to read in each.

Read next