Walk-Forward Analysis
Validate your strategy on data it has never seen
What is Walk-Forward Analysis?
Standard backtesting lets you optimize parameters on your full historical dataset — but the results are misleading, because the strategy has already "seen" that data. It learns to fit past noise, not real patterns. This is called overfitting.
Walk-Forward Analysis (WFA) solves this by splitting the historical data into multiple sequential windows. For each window, it uses the first portion (in-sample / training) to find the best parameters, then tests those parameters on the next portion (out-of-sample / test) that was held out during optimization.
The out-of-sample results are stitched together into a continuous equity curve — a realistic simulation of how the strategy would have performed if you had been running it live. A strategy that holds up well across all folds has passed a much stricter test than one that merely fits a single historical period.
How It Works
The WFA engine executes a precise sequence of steps for every fold.
Fetch & Slice Market Data
Historical OHLCV data is downloaded once for the full requested range. The runner then slices the arrays into per-fold training and test segments without re-fetching.
trainBars, testBars, and stepBars define the window sizes. In anchored mode the training window always starts at bar 0 and grows with each fold.
Compute Fold Windows
computeFoldWindows() walks through the data left-to-right, emitting [trainRange, testRange] pairs. Only folds that fit entirely within the dataset are kept.
Rolling mode: fixed train size, steps forward by stepBars. Anchored mode: train always starts at bar 0, grows each fold. stepBars still controls how far forward the test window shifts.
Optimize on In-Sample Window
The full parameter sweep runs on the training slice. The combo with the highest value for your chosen selection metric (Net P&L, Profit Factor, Win Rate, Total Return, or Min Drawdown) is selected as the "best params" for that fold.
For maxDrawdown the metric is negated — lower drawdown = better score.
Validate on Out-of-Sample Window
The best params from step 3 are run on the held-out test slice in a single-combo backtest. This produces the OOS stats and equity points for that fold.
This is the only result that matters for robustness. A good IS result that degrades badly OOS is a red flag.
Compute Per-Fold WFE
Walk-Forward Efficiency (WFE) for the fold = (OOS return / IS return) × 100. A WFE above 50% suggests the strategy generalises well beyond the training period.
Edge cases: if IS return is 0 the WFE is set to 0. Negative IS returns invert the sign, so WFE can be negative.
Stitch OOS Equity & Aggregate
The equity points from each test window are concatenated (with bar offsets) into a single stitched equity curve. Aggregate statistics — including the composite Robustness Score — are then computed across all folds.
Robustness Score is a 0–100 composite of WFE, profitable-fold %, OOS Sharpe, IS/OOS correlation, and OOS profit factor.
Rolling vs Anchored Mode
Rolling Mode
Each training window has a fixed size (trainBars). As the test window steps forward, the training window shifts forward by the same amount. Only recent data is used for optimisation.
- Best for markets that change over time
- More sensitive to recent regime shifts
- Produces more folds if data is long
Fold 2: train [100–599] test [600–699]
Fold 3: train [200–699] test [700–799]
Anchored Mode
The training window always starts at bar 0 and grows with each fold. More and more historical data is included in each optimisation pass.
- Good for strategies with long-term edge
- Less prone to random variation in training
- Later folds are optimised on far more data
Fold 2: train [0–599] test [600–699]
Fold 3: train [0–699] test [700–799]
Key Metrics at a Glance
Explore the Documentation
Configuration
Set up market data, training & test windows, walk-forward mode, and parameter sweeps.
Folds & Visualizations
Explore the fold table, Gantt timeline, and the IS vs OOS bar chart.
Statistics & Robustness
Understand the Robustness Score, WFE, OOS metrics, and IS/OOS correlation.
Stitched Equity Curve
View the stitched out-of-sample equity curve with fold boundary markers.
Parameter Stability
Visualize how optimal parameters shift across folds to detect over-fitting.
Fold Inspector
Deep-dive into any single fold with full IS and OOS trade statistics.
UI Layout
The WFA panel uses a three-column, fully resizable layout.
- ↳ Market config
- ↳ WFA settings
- ↳ Parameter sweep
- ↳ Presets
- ↳ Run / Stop controls
- ↳ Progress display
- Top (~60%)
- ↳ Fold Table
- Bottom (~40%)
- ↳ Tab: Equity Curve
- ↳ Tab: IS vs OOS Chart
- ↳ Tab: Fold Gantt
- ↳ Tab: Param Stability
- Top (~40%)
- ↳ WFA Statistics
- Bottom (~60%)
- ↳ Fold Inspector
- • IS / OOS tabs
- • 8 stat sections
All columns are draggable. The center column also has a top/bottom drag divider between the fold table and the chart area.