Walk-forward analysis: slices, training share and selection

Walk-forward splits the backtest period into slices, picks the best parameter configuration on the training part of each slice, evaluates it on the test part it never saw, and reports the concatenated out-of-sample result with an efficiency figure and a deflated Sharpe.

Senzoukria · Documentation · Updated September 2026


Where to find it

Where
Replay → Prepare → Automatic backtest → checkbox 'Walk-forward — find the best configuration'
Defaults
Slices 4, Training share 0.7, Selection criterion SQN
Combinations
Maximum 400; a configuration needs at least 10 trades to be selectable
Minimum data
Each slice needs at least 100 training bars and 50 test bars

What it does

Testing thirty configurations and keeping the best measures luck. Walk-forward separates the choice from the measurement: parameters are chosen on the start of each slice, then evaluated on the end of it, which took no part in the choice. The result shown is the concatenation of those never-seen pieces, which is what the strategy would really have returned.

Implementation (lib/replay/autoBacktest.ts, runWalkForward): the bars are cut into equal slices; within each slice the first trainRatio of bars is the training window and the rest is the test window. Every combination of the sweep axes is run on the training window, scored with the selection criterion, and the best is run once on the test window. Out-of-sample trades of all slices are concatenated and the combined statistics are computed on them. Progress reads 'slice n · training' then 'slice n · test'.

Settings

Walk-forward settings in the Automatic backtest card
SettingDefaultWhat it changes
Walk-forward toggleOffShows the settings below and changes the run button to 'Run the walk-forward'.
Slices4Number of folds, 2 to 12. More slices mean shorter training windows; the run refuses a split that leaves fewer than 100 training or 50 test bars.
Training share0.7Share of each slice used to choose parameters, 0.5 to 0.9 in steps of 0.05.
Selection criterionSQN (quality, accounts for the number of trades)Also Profit factor, Expectancy per trade or Sharpe per trade. A configuration with fewer than 10 trades scores minus infinity.
Parameters to sweepAxes read from the script's params, else lookback 10, 20, 40 / stopTicks 20, 40, 80 / targetTicks 40, 80, 160Comma-separated values per axis; 'Explore every readable parameter' sets up to five axes around the script's defaults; 'Re-read the script' restores them.
Combinations line'{n} combinations × {folds} slices — about {dur}', or 'Too many combinations (maximum 400)'.

Reading the result

  • Walk-forward efficiency = mean out-of-sample expectancy divided by mean in-sample expectancy across slices. At 70 % or more: 'the strategy holds up outside its own data'; from 40 %: 'it loses a good part of its edge out of sample'; below: 'most of the result was overfitting'. Under 50 % the line is highlighted as bad.
  • Deflated Sharpe: the out-of-sample Sharpe per trade against the threshold that selection alone would produce over the number of configurations tried. Verdicts: solid (survives the correction), fragile (the number of configurations explains a good part of it), noise (not distinguishable from the best of a random draw).
  • Fold table: Slice, Training, Real test, Config, so you can see whether the chosen configuration jumps from slice to slice.
  • Charts: in-sample versus out-of-sample equity (dashed for the curve the optimiser saw), and parameter stability comparing the chosen configuration with its grid neighbours (plateau, slope or peak).
  • The combined out-of-sample statistics are what gets recorded in the Performance panel.

Limits or pitfalls

Every extra combination is one more draw in the same data; past a point you measure the luck of an overfit, which is why the cap is 400 and the assistant is told to keep sweeps under 100. Sweeping five axes on one month of 15-minute bars will produce a winner that means nothing.

Slices are cut by bar count, not by calendar; a slice can straddle a regime change. The sweep runs each combination as a full backtest, so runtime grows linearly with combinations × slices, and 1-minute bars over long periods take hours. The walk-forward uses the same fill rules and costs as the plain backtest, and it never places an order.

This page in other languages

Frequently asked questions

What does a walk-forward efficiency of 45 % mean?
On average the out-of-sample expectancy was 45 % of the in-sample one: the strategy lost a good part of its edge on data it had not seen. Below 50 % the panel highlights it and the assistant is told to say plainly that most of the result was curve fitting.
Why does the run refuse my number of slices?
Each slice must keep at least 100 training bars and 50 test bars. With a short period or many slices that is not met; reduce the slices or lengthen the period.
Which criterion should I select on?
The default is SQN because it folds the number of trades into the score. Profit factor, expectancy per trade and Sharpe per trade are available; whatever you choose, a configuration with fewer than 10 trades is never selected.

Keep reading