Walk-Forward Optimization
Split the time series into successive (in-sample, out-of-sample) windows. Optimize on each in-sample window, evaluate on its out-of-sample window, then roll forward. Anchored walk-forward keeps the in-sample window starting at t=0 and growing; sliding walk-forward keeps the in-sample window length fixed and slides it. The concatenated out-of-sample returns are the honest backtest equity curve.
On This Page
Definition
Walk-forward optimization
Split the time series into successive (in-sample, out-of-sample) windows. Optimize on each in-sample window, evaluate on its out-of-sample window, then roll forward. Anchored walk-forward keeps the in-sample window starting at t=0 and growing; sliding walk-forward keeps the in-sample window length fixed and slides it. The concatenated out-of-sample returns are the honest backtest equity curve.
Why it matters
Single-period in-sample/out-of-sample splits hide regime risk. Walk-forward forces the strategy to adapt the way a live system would — re-fit, deploy, observe — and exposes parameter drift, overfitting, and regime-dependent collapse before live capital is at stake.
How it works
Choose window length and step size. Optimize parameters on window i (in-sample). Evaluate on window i+1 (out-of-sample). Record OOS performance. Slide forward by step size, re-optimize, repeat. Concatenate OOS performance across windows — that's your honest backtest. Watch for parameter drift across windows: a strategy whose optimal parameters wander from window to window is signaling that the underlying edge is unstable.
Example
Mean-reversion strategy, 5 years daily, 1y in-sample / 3mo out-of-sample, sliding
In-sample windows
16
Mean in-sample Sharpe
1.9
Mean out-of-sample Sharpe
0.6
OOS / IS ratio
0.32
OOS Sharpe is one third of IS Sharpe. That's the realistic live-trading expectation — not the 1.9 from the IS fit.
Key Takeaways
OOS / IS ratio below 0.5 is a red flag — the strategy probably won't survive live.
Anchored walk-forward grows the in-sample window monotonically; sliding keeps it fixed length. Pick based on whether you believe the data-generating process is stationary.
Re-tuning parameters too frequently vs the OOS window is meta-overfitting.
Related Terms
Try These Tools
Run the numbers next
Walk-Forward Validator
Upload a returns CSV. Rolling or expanding IS/OOS windows, per-window Sharpe, walk-forward efficiency, and a concatenated OOS equity curve. Catches regime.
Walk-Forward Validation Visualizer
Paste a strategy returns CSV, get per-window in-sample vs out-of-sample Sharpe and the IS→OOS drop. Rolling and anchored window modes. Browser-only.
Backtest Overfitting Score
Upload a backtest trade log and compute Probability of Backtest Overfitting (PBO), Deflated Sharpe Ratio, and the odds your edge survives live trading.
FAQ
Questions people ask next
The short answers readers usually want after the first pass.
Sources & References
- Advances in Financial Machine Learning, Chapter 7 — Cross-Validation in Finance — Lopez de Prado (2018), Wiley
- The Deflated Sharpe Ratio: Correcting for Selection Bias, Backtest Overfitting, and Non-Normality — Bailey, Lopez de Prado (2014), SSRN
Related Content
Keep the topic connected
Overfitting
Overfitting in trading-strategy backtests: how multiple-testing inflates apparent edges and the diagnostics that catch it.
Bailey-Lopez de Prado PBO
Probability of Backtest Overfitting: a combinatorial test that estimates how likely your best in-sample strategy is to underperform out-of-sample.