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

Defenses that actually help

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.