The signature of an overfit ONNX EA is simple: a gorgeous equity curve in the Strategy Tester and a flat or negative one live. Overfitting is not a bug in your model — it is what optimization does by default. The job is to make it hard to fool yourself.
Where overfitting sneaks in
- Too many features relative to data (see feature engineering).
- Threshold curve-fitting — tuning the confidence cutoff on the same data you evaluate on.
- Reusing the test set — every peek is a little more leakage.
- Normalization leakage — stats computed over the whole series.
Defenses that actually help
- Walk-forward validation, judged on the distribution of folds, not the best one (guide).
- A locked holdout you evaluate once, at the very end.
- Simpler models — a shallow tree or small net generalizes better than a deep one on noisy price data.
- Regularization and early stopping.
- A confidence gate so the EA only trades high-probability setups (how).
The Strategy Tester trap
Even a well-validated model can look wrong in MT5 if normalization differs between training and inference. Before blaming overfitting, rule out the normalization bug in Strategy Tester.
A sane workflow
Engineer a compact feature set, validate walk-forward, choose thresholds on validation folds, confirm once on a locked holdout, then ship the model as a filter. If live tracks your out-of-sample distribution, you did it right.
Frequently asked questions
My backtest is great but live is flat - is it overfitting?
Usually yes, unless it is a normalization mismatch between Python and MQL5. Re-check with walk-forward validation and confirm your live features and scaling match training exactly.
What is the single best defense against overfitting?
Walk-forward validation combined with a holdout you evaluate only once. Judge the model on out-of-sample consistency, not the best-looking fold.
Running this live?
See which prop firms allow ONNX-driven EAs, or compare MT5 brokers for running an ML EA.