Skip to content

Backtest Lab — Walk-forward

Roll train/test windows forward through history to get out-of-sample metrics per window and detect overfitting.

Walk-forward analysis splits your window into rolling train and test (out-of-sample) segments, steps them forward through history, and reports metrics per test window. It’s the Lab’s overfitting check: parameters that only look good in-sample tend to fall apart on the test segments.

How the windows are built

The Lab constructs a sequence of rolling windows from your base config’s startDate/endDate:

  • Each window has a train span followed by a test span.
  • Windows roll forward so successive test segments cover later, unseen periods.
  • Date math is pure UTC calendar arithmetic — month addition clamps day-of-month overflow (Jan 31 + 1 month → Feb 28/29, never Mar 2/3), and every window’s start is derived from the original startDate so rounding never compounds into drift.

Reading the results

You get an out-of-sample summary across windows plus per-window metrics. What to look for:

  • Consistency — are the test-window metrics stable, or all over the place?
  • In-sample vs. out-of-sample gap — a big drop from train to test is the classic overfitting signature.
  • Worst window — a strategy is only as dependable as its bad periods.

Workflow

Walk-forward is the third step of a disciplined Lab loop:

  1. Sweep to find promising parameters.
  2. Walk-forward to confirm they survive out-of-sample.
  3. Compare the survivor against baselines.