Walk-Forward Testing and Overfitting
Set your selection rule before viewing the test results. After testing a window, you can use it to develop the next rule, then evaluate that rule in a later window.

Exercise 2 · Does the best rule hold up?
Each of the five windows compares six lookbacks on the preceding 300 synthetic hours. The rule with the highest net pips is selected for the next 300 hours. Trades stay within their window and exit after six hours. Costs are 1.2 pips per completed trade.
| Rule | Lookback (hours) | Development (pips) | Test (pips) |
|---|---|---|---|
| Walk-Forward | |||
| Fixed lookback | |||
| Best in hindsight |
In the first test window, the rule chosen in advance loses 49.24 pips. The fixed 12-hour rule loses 1.13 pips.
The rule selected in hindsight uses the same test data it is scored on. This shows how hindsight can flatter a result. Change the window and compare the other two rules.