Walk-Forward Analysis

Definition

Walk-forward analysis is a validation method that repeatedly fits a strategy's parameters on a past training window and then evaluates them, unchanged, on the next unseen test window, moving both windows forward through history. Performance is judged only on the stitched-together test windows.

How it works

Each fold has a strict order: training data must end before test data begins, so parameters are chosen using only the past. A rolling version keeps the training length fixed and drops the oldest data; an anchored version keeps the start fixed and lets the training window grow. If indicator lookbacks or holding periods overlap the boundary, leave a gap between the windows.

Because re-optimization is part of the strategy, it is repeated at every fold and judged out of sample. Window lengths still involve a trade-off: short windows give noisy parameters, while long ones adapt slowly to changed conditions.

Formula / convention

Number of folds = (Total periods − Training length) ÷ Test length, when the step equals the test length and the periods divide evenly

Illustrative example

Illustrative: 120 months of data, a 36-month training window and a 12-month test window stepping forward 12 months at a time. The first fold fits on months 1–36 and tests on months 37–48, the last fits on months 73–108 and tests on months 109–120, giving (120 − 36) ÷ 12 = 7 folds and 84 out-of-sample months; months 1–36 never appear in the test record.

What to watch for

Walk-forward results are still one historical path, and changing window lengths or rules after seeing the out-of-sample results turns them back into in-sample tuning. Include trading costs, and treat a large drop from in-sample to out-of-sample performance as a sign of overfitting.