Walk-Forward Testing
Walk-forward testing divides your historical data into alternating optimization and validation windows, producing a final equity curve composed entirely of out-of-sample performance.
How it works in BacktestLM
- 1You run a standard backtest and enable Walk-Forward Optimization from the options panel.
- 2You configure the in-sample (IS) and out-of-sample (OOS) window lengths. Common ratios: 3:1 (IS:OOS) or 4:1.
- 3The engine runs a parameter optimization on each IS window and selects the best-performing configuration.
- 4The winning parameters are applied unchanged to the following OOS window. The engine records the OOS performance.
- 5Windows roll forward across the full dataset. The final combined OOS equity curve is the walk-forward result.
Configuration options
In-Sample window length
The number of months (or bars) used for parameter optimization in each cycle. Longer IS windows produce more stable parameter selections but fewer OOS cycles.
Out-of-Sample window length
The number of months (or bars) used for validation in each cycle. Longer OOS windows give more reliable per-cycle estimates but mean the strategy may be re-optimized less frequently.
Optimization metric
The metric used to select the best parameters in the IS window. Options: Sharpe Ratio (default), Total Return, Profit Factor, or Calmar Ratio.
Parameter search space
The range of parameters to optimize in each IS window. Defined the same way as grid search. Broader ranges increase BTU cost.
Reading the results
Combined OOS equity curve
The stitched-together equity curve from all OOS windows. This is the primary result — treat it as the walk-forward strategy performance.
Per-cycle table (IS Sharpe / OOS Sharpe)
Shows IS and OOS Sharpe for each cycle. Look for consistency: all or most cycles should be profitable OOS, and OOS should be reasonably close to IS.
IS/OOS degradation ratio
OOS Sharpe divided by IS Sharpe. Values above 0.7 indicate healthy degradation. Values below 0.5 suggest curve fitting.
Parameter selection per cycle
Which parameters were selected in each IS window. Stable selection (similar values across cycles) indicates a robust parameter region. Wildly varying selections indicate instability.
Common interpretation mistakes
- Using the IS Sharpe as the strategy Sharpe — always report and evaluate the OOS Sharpe, not the IS Sharpe.
- Re-optimizing after seeing OOS results — once you have seen the OOS results, using them to refine parameters makes those results in-sample. The OOS is no longer unbiased.
- Too few OOS cycles — fewer than 4 OOS cycles provides limited statistical evidence. Use a longer data history or shorter window lengths to increase the number of cycles.