Walk-forward tests with rolling windows
A walk-forward test repeats the sequence of training on available history, choosing parameters on a later validation window and running the frozen choice on the next test window. Decide the window lengths and selection score before inspecting test results.
| Fold | Training | Validation | Test |
|---|---|---|---|
| 1 | Jan–Jun 2024 | Jul–Sep 2024 | Oct–Dec 2024 |
| 2 | Apr–Sep 2024 | Oct–Dec 2024 | Jan–Mar 2025 |
At the second decision date the previous test period is historical and can be used by the predetermined procedure. When you use the combined results to change the procedure itself, reserve another untouched period as a final check. Concatenate only test-window results with nonoverlapping dates.
Inspect each split boundary
If a target uses the next five bars, end training early enough that those future observations stay inside the training block. Apply the same idea to validation. Fit any scaler or missing-data model on training data only. Price history before a test window may warm the frozen indicators if it was already available.
Define position handling at the boundary. A continuous simulation carries positions and transaction costs through each transition, while an independently reset fold should count that reset in its interpretation. Record the chosen parameters, trade count, costs and drawdown per fold to see which regime drives the result. TimeSeriesSplit and its gap parameter · Detect look-ahead bias.