How to Algo

Walk-Forward Analysis and Out-of-Sample Testing

How to split train and holdout before you look, run walk-forward windows, and treat a sign flip between halves as a kill signal, with real futures cases.

Part 13 of 20 · How to Algo · Previous: Placebo tests · Next: Overfitting and robustness

Every look at data changes you. Once you have seen how a strategy did in 2024, you cannot design the 2024 version of it without that knowledge, even if you try. Out-of-sample data is therefore a resource you spend, not a test you can repeat. Decide the split before the first run, touch the holdout once, and accept what it says.

This part covers how to split, how walk-forward testing works, what a fair out-of-sample number is, and what our own holdouts have done to results that looked solid in-sample.

Leave-one-year-out walk-forward of an NQ Asian-session sweep, 2019 to 2026: every fold trained at t above 2, two held-out years lost 18,144 and 21,774 USD, total out of sample -22,598 USD

The basic split

The simplest out-of-sample test is a single split by date:

  • Training years: used to design the rule, choose parameters, compare variants.
  • Holdout years: run once at the end with everything frozen.

Three rules make it work:

  1. Decide the split in advance and write it in the hypothesis sheet (Part 1). A split chosen after seeing the curve is a parameter.
  2. Put the holdout at the end. It is closest to the market you will trade and protects against the most common failure, a market that has changed.
  3. Run it once. If you look at the holdout, change something and look again, the holdout has become training data.

The length of the holdout follows from Part 10: it needs enough independent observations to say something. For intraday strategies a couple of years can contain hundreds of trades. For daily strategies trading 25 times a year, a two-year holdout is 50 trades, which can confirm a strong edge and cannot reject a weak one.

Sign flips are the kill signal

The most useful thing a holdout tells you is not the exact number but its sign.

A fully specified NQ VWAP strategy. The author fitted it on 2020–2023 and published out-of-sample claims for the years after. We rebuilt it from the interview; it reproduced his in-sample numbers within a few percent, +$111,720 over 2020–2023. From 2024 to August 2026, his own out-of-sample window, it made −$16,960 at t = −0.4. Part 9 explains the mechanism; the Conti test has the details.

An Asian-session sweep reversal on NQ. We chose parameters from 80 combinations on 2019–2022 only. Training: t = +2.00, $72 a trade. Holdout: t = +0.06, $2.70 a trade. Of the 80 combinations, 47 were positive in the holdout, 59%, little better than a coin.

Composite volume-profile reversion on NQ. Point-of-control, value-area and VWAP reversion rules on daily bars all changed sign between training and holdout: negative in one, positive in the other. That is the signature of a regime, not an edge.

A sign flip is not a reason to try a different split. If the relationship is real, it should hold in both halves; if it only holds in one, you have learned when it did not work, which is the more important half.

Walk-forward testing

A single split uses one training period and one test period. Walk-forward repeats the process:

  1. Choose a training window (for example four years) and a test window (one year).
  2. On the training window, select parameters by whatever rule you use.
  3. Apply them unchanged to the test window and record the trades.
  4. Move both windows forward by the test length and repeat.
  5. Join all test windows into one out-of-sample equity curve.

Two variants are common. Anchored walk-forward keeps the start of the training window fixed and grows it; rolling walk-forward keeps the training length constant. Anchored is more stable; rolling adapts faster to a changing market. For a small number of years, a leave-one-year-out design is often the most informative: for each year, choose parameters on all the other years and test on the one left out.

Walk-forward answers two questions at once:

  • What would I have earned choosing parameters as I went? That is the realistic number.
  • How often did the chosen parameters change? If the winner jumps around every window, the search is fitting noise.

The Asian sweep is the cautionary example, and the chart at the top of this article shows it fold by fold. A leave-one-year-out walk-forward over the full 3,000-combination grid lost $22,598, and the chosen configuration changed almost every year: different start hours, fade one year, follow the next. Every one of the eight training windows cleared t = 2, from +2.04 to +2.31. The held-out years paid between +$558 and +$5,886 in six folds, and two of them, 2021 and 2024, lost $18,144 and $21,774. The 3,000-combination test.

Scatter of the eight folds: training t-statistic of the chosen parameters (all between 2.04 and 2.31) against the held-out year's result in USD thousands; correlation -0.10

Plotted against each other, the training t and the held-out result have a correlation of −0.10. A higher in-sample t did not predict a better year.

The ES RSI-2 test is the opposite case. All twenty threshold-and-hold cells were positive in both halves of the window. Even so, a walk-forward would have picked different cells at different times, and its total was $222,942 against $250,678 for the best cell in hindsight. The walk-forward number is the one to plan with. The one that survived.

Holdouts across markets and time

A date split is not the only kind of holdout.

Another instrument. A rule developed on NQ can be tested once on ES, or the reverse. For a machine-learning candidate on NQ we wrote down before the run that a flat or negative ES result would mean the NQ result was chance. ES came back at t = +0.22 and we stopped. The same happened to an opening-range breakout: ORB30 long-only survived our Nasdaq audit at Sharpe 1.60 and, frozen and run once on ES, lost $28.53 a trade (ORB on ES). In the other direction, our NQ RSI-2 rule replicated on twelve years of ES, and the extra years showed two red ones the Nasdaq window never contained. Cross-instrument holdouts are strong when the mechanism should travel and weak when it is instrument-specific, so say in advance which you expect.

Another session. We ported several NQ rules to the Asia and London sessions. Most did not travel, and the session audit is useful as a holdout precisely because the rules were frozen before the port.

Live paper trading. The final holdout is the market itself. Part 19 covers reconciling it with the backtest.

Walk-forward for models

Models need walk-forward even more than rules, because they have more freedom to fit. For a tick-level classifier on NQ we used 60-day training and 20-day test windows across a year. Nine folds produced AUCs between 0.5002 and 0.5076: nothing. One fold, in May and June 2026, collapsed to hit rates of 3–21% while the number of trades exploded: a regime the training window did not contain. A single train/test split could easily have missed that window, or been entirely inside it.

”Candidate” is an honest verdict

Not every result ends in a clean pass or fail. A put/call volume contrarian on ES was significant over the full sample at t = 2.43, with t = 2.05 in the first half and t = 0.84 in the holdout. Positive in both, significant in neither half. We published it as a candidate, not a sleeve. That category is worth having: it stops you from either deploying a result the holdout did not confirm or burying one it did not reject.

Checklist

  1. Write the split into the hypothesis before the first run.
  2. Put the holdout at the end of the data.
  3. Run the holdout once, with everything frozen.
  4. Treat a sign flip between halves as a kill.
  5. Use walk-forward to get the realistic number; plan with it, not with the best cell.
  6. Track how often walk-forward changes its chosen parameters.
  7. For few years of data, use leave-one-year-out.
  8. Use another instrument or session as a pre-declared holdout where the mechanism should travel.
  9. Walk-forward every model, and look at each fold separately.
  10. Allow “candidate” as a verdict when the holdout neither confirms nor rejects.

Walk-forward tells you whether parameters chosen in the past still work. The next part asks whether the parameters were ever more than a lucky peak. Part 14: Overfitting and parameter robustness.

Frequently asked questions

What is the difference between walk-forward and out-of-sample testing?

An out-of-sample test uses data that played no part in designing the strategy, usually one split by date, run once. Walk-forward repeats that split: choose parameters on a training window, apply them unchanged to the next window, roll forward and join the test windows. One split gives one verdict; walk-forward gives one per window.

Can you reuse an out-of-sample period?

No. If you look at the holdout, change something and look again, the holdout has become training data. Decide the split before the first run, run the holdout once with everything frozen, and accept what it says.

How much data should be held out for out-of-sample testing?

By date, decided before the first run, with the holdout at the end so it is closest to the market you will trade. Make the holdout long enough to contain a few hundred independent trades or several years for daily strategies. Write the split into the hypothesis sheet and do not move it after seeing results.

What does it mean when a strategy flips sign out of sample?

That the in-sample result was fitted to that period. A rule that is positive in training and negative in the holdout, or the reverse, has no stable relationship with the market. We treat a sign flip between halves as a kill criterion, not as a reason to search for a better split.

How much worse should out-of-sample results be?

Some degradation is normal because the in-sample number includes selection. A walk-forward that picks parameters honestly is the realistic estimate. For our ES RSI-2 test, all twenty parameter cells were positive in both halves, but a walk-forward would have chosen different cells over time; the walk-forward total was $222,942 against $250,678 for the best cell, and the lower number is the one to plan with.

Keep reading

How to Algo

Backtest vs Live Trading: Reconciling Every Trade

Why live trading drifts from the backtest: fills, latency, data gaps, rolls and code divergence. How to replay your live engine and reconcile trade by trade.

How to Algo

Tick Data vs Bars: What Resolution Your Algo Needs

Daily bars, minute bars, ticks or order-book depth? Match data resolution to the decision your algo makes, and see what a bar hides about stops and targets.