Walk-forward analysis step by step for a retail EA
Walk-forward analysis is your best defense against curve-fitting. Instead of testing over the whole dataset at once, you break it into chunks. You train on an in-sample (IS) window and then test that specific parameter set on the immediate out-of-sample (OOS) period. You repeat this, shifting the windows forward like a sliding scale.
A common approach for retail EAs is a rolling window. If you have ten years of data, try a two-year IS and a six-month OOS. This forces the model to prove it works on data it hasn't seen yet. An anchored approach, where the IS window keeps growing, is another option, but it often leads to overfitting on the initial, older data points.
Here is what you look for in a passing result:
- Consistency in performance metrics across all OOS segments.
- No massive drawdown spikes in the OOS windows that weren't present in the IS.
- A similar win rate and profit factor across different time slices.
The biggest mistake people make is 'peeking' at the OOS data. If you optimize your strategy, check the OOS, and then tweak the indicators because the OOS was poor, you are just curve-fitting manually. You have effectively turned your OOS into IS data. Once you start tuning based on OOS results, the entire integrity of the validation process is gone.
Another trap is choosing window sizes that are too small. If your IS window is only a few months, you capture too much noise and not enough regime behavior. You end up with a strategy that excels in a specific market condition but fails as soon as the volatility shifts. Always keep your windows large enough to capture at least a few meaningful market cycles. How are you handling the transition between your IS and OOS segments to avoid look-ahead bias?