TradeViora AcademyLearn. Analyze. Practice. Trade Smarter.
Menu

FREE FINANCIAL EDUCATION

Walk-forward testing

Build sequential training and test windows without future leakage.

0%

What you will learn

Prerequisites: Chronological data splits, parameter fitting and forward evaluation.

Mechanism and decision rules

Walk-forward testing repeats a historical deployment sequence: fit or select parameters on past data, freeze the chosen configuration, then evaluate on the next unseen interval. Advance the timeline and repeat. A rolling training window keeps a fixed recent length; an expanding window retains all earlier training history. These choices express different assumptions about relevance and regime change.

Any preprocessing, feature selection and threshold tuning must occur inside each training window. Test outcomes cannot influence that same fold’s fitted rule. Overlapping labels or holding periods can cross the boundary, so a gap or purging procedure may be needed. Combining all training profits with test profits would defeat the purpose; the evaluation curve should use the forward segments under their actual chosen parameters.

Worked example · synthetic data

A synthetic plan trains on months 1–6 and tests on 7, then trains on 2–7 and tests on 8, then trains on 3–8 and tests on 9. This is a six-month rolling window. An expanding alternative would train 1–6, then 1–7, then 1–8.

Suppose test-month net returns are +2%, −1% and +1.5%. The compounded forward result is 1.02 × 0.99 × 1.015 − 1 ≈ 2.4947%. Adding the best training-period return to this number would contaminate the forward evaluation with fitted performance.

Failure modes and limits

Walk-forward results can still be overfit if window lengths and selection procedures are repeatedly chosen using the same evaluation history. Fold samples may be dependent and small. A gap handles some timing overlap but cannot repair a noncausal feature. Deployment costs and model-retraining operations also need simulation.

Practice case

An expanding test trains on days 1–100 and tests 101–120. The next fold tests 121–140. What is the next training range under an expanding policy? If labels use the next five days, what boundary issue needs attention?

Reveal the worked answer

The next training range may extend through day 120 under the stated expanding policy. However, training labels near the boundary can depend on outcomes inside the test interval. Exclude or purge overlapping observations, or add an appropriate gap based on label availability, before fitting.

Check your understanding

Rolling six-month training after months 1–6 typically moves to what?


Explanation

A rolling window advances while keeping its length fixed.

Where must a feature scaler be fitted in each fold?


Explanation

Preprocessing is part of the learned pipeline and must respect the training boundary.

What curve should summarize forward evaluation?


Explanation

Selecting or mixing fitted returns inflates the reported evidence.

Sources and next steps

The lesson, calculations and synthetic cases are original educational material. References explain underlying contract or chart conventions; none validates the profitability of a trading rule. Actual contract specifications, settlement obligations and charges must be checked before trading.

Explore OHLCV data in the chart lab · Explore volume-at-price and TPO data · Practice library