Skip to content
Back to Blog
  • Backtesting
  • Quantitative Trading

How to Run a Walk-Forward Test on a Trading Strategy (Step by Step)

Seven steps to a walk-forward test that trains only on the past, reports every fold, and keeps a final holdout.

Agon Research Team4 min read

A walk-forward test chooses a strategy's parameters using only past data, then evaluates them on the next period the optimizer has never seen, and repeats the process as it rolls forward through history. It is closer to the decisions a live system faces than one large backtest, and it exposes parameters that only worked in one period.

Key takeaways

  • A walk-forward test optimises on past data only, then tests the frozen parameters on the next unseen window, and rolls forward.
  • Fix the rules, ranges, costs and pass criteria before running it, and report every fold, not the best one.
  • Keep a final locked holdout: walk-forward reduces overfitting but does not remove it.

Step 1: Fix the rules before you look

Write down the strategy's rules, the parameter ranges you will search, the costs you will apply and what counts as a pass, for example positive net results in most test windows and no worse than buy-and-hold on the same pair and period. Deciding afterwards turns the test into a search for a story.

Step 2: Split history into sequential windows

Divide the data into consecutive pairs of windows: a training window followed by a test window. The test window always comes after its training window, never before or overlapping it.

Rolling and anchored walk-forward windows
SchemeTraining windowSuitsWatch out for
RollingFixed length; drops the oldest data as it movesMarkets whose behaviour changes over timeFewer data points per fit
AnchoredStarts at the beginning and growsRelationships expected to be stableOld regimes keep influencing the fit

Step 3: Optimise on the training window only

Search the parameter ranges on the training window, with costs included, and pick the configuration your pre-set rule selects. Nothing from the test window may influence that choice.

Step 4: Freeze the parameters and run the next test window

Apply the chosen parameters, unchanged, to the following test window and record the result, net of fees, funding and slippage.

Step 5: Roll forward and repeat

Move both windows forward by the length of the test window and repeat steps 3 and 4 until the end of the data. Each repetition is one fold.

Step 6: Report every fold, not the best one

Stitch the test windows together into one out-of-sample record, and also show each fold separately. A strategy that wins in one fold and loses in the rest is a story about that one period. Comparing out-of-sample performance with in-sample performance (sometimes called walk-forward efficiency) shows how much of the backtest survived contact with new data.

Step 7: Keep a final holdout

Walk-forward analysis does not remove overfitting if you keep redesigning the strategy around its results. Lock a final period that none of the steps above touches, and evaluate on it once.

What are the most common walk-forward mistakes?

  • Choosing the window lengths after seeing which ones look best.
  • Letting information from the test window leak into the training window, for example through indicators that use future bars.
  • Reporting only the aggregate equity curve, which hides weak folds.
  • Leaving out costs, so that a strategy which trades often looks better than it is.

How does Agon use walk-forward testing?

In Agon, every strategy goes through backtest, Monte Carlo, walk-forward and paper trading, and must pass walk-forward validation before real-money mode is unlocked. In our own research, several attractive ideas weakened or failed when judged fold by fold.

Frequently asked questions

How long should the training and test windows be?

Long enough for the training window to contain a meaningful number of trades and for the test window to cover more than a few days of the strategy's typical holding period. Choose the lengths before running the test.

Is walk-forward testing the same as cross-validation?

No. Standard cross-validation shuffles or reuses data in any order, which lets the future leak into training. Walk-forward testing always trains on the past and tests on the future, as live trading does.

Does passing walk-forward mean a strategy will make money?

No. It means the strategy's parameters held up on data they were not chosen on, in the past. Markets change, and live costs can be higher than modelled.

Research, not investment advice.

Stay Updated

Subscribe to our newsletter to receive the latest trading insights, platform updates, and market analysis directly in your inbox.