EA developers are running Python-trained ML models directly inside MetaTrader 5 now. Not proofs of concept. Live accounts, real money.
We've tested a handful of ONNX-powered EAs over the past year at FXTool. Some of what we found was not what we expected. This is what ONNX actually changes, and whether it matters for you.
The old way was painful
Most EAs run on rules. Moving average crossovers, RSI thresholds, Bollinger Band breakouts. Been working for over a decade. Not obsolete, but you hit the ceiling fast.
Then someone asks: what if we added machine learning?
You train your model in Python — TensorFlow, PyTorch, whatever. But EAs run in MQL5. Two different worlds with no bridge between them. Your options used to be: rewrite the trained model in MQL5 from scratch (structure, weights, preprocessing, everything), or give up.
Linear regression? Maybe you can pull it off. LSTM? CNN? Transformer? Forget it.
We actually tried porting an LSTM price prediction model to MQL5 back in 2024. Took three weeks. Never got the accuracy to match. Scrapped it.
ONNX in 30 seconds
ONNX stands for Open Neural Network Exchange. Microsoft, Meta, and Amazon are behind it.
Whatever framework you trained your model in (PyTorch, TensorFlow, scikit-learn, XGBoost), you export it to a single .onnx file. Any platform with ONNX Runtime can load that file and run inference. That's the whole idea.
PDF for AI models, basically. Doesn't matter what created it. Everyone can open it.
MT5 now supports ONNX natively
MetaTrader 5 has ONNX Runtime built in. Your EA calls OnnxCreate() to load a model, OnnxRun() to get predictions. No plugins, no external processes, no API calls.
MetaQuotes has been pushing this hard. The Build 5572 update from January 2026 added:
- CUDA GPU acceleration. If your card supports CUDA, inference gets much faster. Matters for strategies that run predictions on every tick.
- Multi-GPU selection. Pick which GPU runs the model if you have more than one.
- Model profiling. See per-layer execution times to find where it's slow.
- 1GB resource limit. Big models can be embedded directly into EAs now.
MetaQuotes isn't treating this as a side feature. They're building around it.

The workflow: four steps
Simpler than it sounds:
Train in Python. Grab historical price data, say 120 H1 bars of OHLC, and train something that predicts the next bar's direction. XGBoost, LSTM, CNN, whatever fits.
Export to ONNX. tf2onnx for TensorFlow, torch.onnx.export() for PyTorch, skl2onnx for scikit-learn. Pin the input tensor shape.
Load in MQL5. OnnxCreateFromBuffer() or OnnxCreate(). Set input dimensions with OnnxSetInputShape().
Run it. In OnTick() or OnBar(), normalize your latest data (has to match training preprocessing exactly), call OnnxRun(), use the prediction in your trade logic.
Python trains. MQL5 runs. The .onnx file sits between them. Zero ML code in MQL5.
New to EA development? Start with our guide to what EAs actually are.
The community is already shipping
Not theoretical. The MQL5 community has working examples:
Larry Williams XGBoost ONNX EA. Classic Outside Bar price action + XGBoost probability filter. Rules find the setup, the model scores win probability. Rules decide when, AI decides whether.
CNN-LSTM hybrid. Full implementation in MQL5 tutorial articles. CNN pulls spatial features from price sequences, LSTM handles the time dependencies. EURUSD H1, R² of 0.9684. The author says don't trade it live, but it shows the ONNX pipeline doesn't degrade the model.
ONNX Strategy 1. Five deep learning models running at once, one trained just for gold. Majority vote decides the trade.
A developer wrote a post titled "How I Built a Hybrid, ML-Powered EA for MT5 (And Why a 'Black Box' Isn't Enough)". His argument: pure ML without traditional TA as a sanity check will blow up.
We've run several public ONNX EAs ourselves. The pattern is consistent: everything that works in production is a hybrid. AI plus rules. Pure AI decision-making? Haven't seen one last three months live.
Makes sense if you know about overfitting and curve fitting. Data-only models are brittle in financial markets.
The bigger picture
Not just an MQL5 thing.
NVIDIA's 2026 Financial Services AI Survey says nearly every surveyed institution plans to increase or hold AI budgets. Algo trading is roughly 70% of U.S. equity volume. Over 80% of institutions use AI somewhere.
What's more interesting is the size trend. The industry is moving away from hundred-billion-parameter models toward sub-7B specialized ones. Trading is latency sensitive. An accurate model that's slow to infer can lose to a slightly dumber model that responds instantly.
For retail EA developers, this is actually encouraging. You don't need an A100 cluster. A consumer GPU, or even CPU only, running a small model tuned for one instrument might be enough.
The pitfalls — from experience
We've hit all of these. Saving you the time:
Overfitting. Looks perfect on training data, falls apart live. Not an ONNX problem, a modeling problem. Cross-validation, walk-forward analysis, out-of-sample testing. Skip any of these and you're fooling yourself. We wrote a whole piece on the gap between backtest and live results.
Preprocessing mismatch. You normalized to [0,1] with Min-Max during training? You need the exact same parameters at inference. Off by a little and the output is noise. Almost every beginner gets burned here.
Models go stale. Market structure shifts. Something trained six months ago might be mostly wrong today. You need to monitor performance and retrain. How often depends on the instrument and timeframe, but "set and forget" doesn't work.
Look-ahead bias. Train on future data, backtest looks incredible. Obviously. Live markets don't hand you the future. Train/test splits go strictly by time.
Bottom line
ONNX won't fix a bad strategy. What it does is take something that used to need an institutional quant team and hand it to anyone who knows Python. The infrastructure is there now: native MT5 support, GPU acceleration, a growing pile of community examples that actually run.
So the question has shifted. Not "can I put ML in my EA" but "is my model worth putting in."
If you're still figuring out the EA side, start with our forex beginner's guide or how to choose an EA.
About the author: The FXTool team builds and tests MetaTrader trading tools daily. We run every EA we sell on live accounts and publish the results. This guide reflects what we've learned from building 50+ EAs and working with thousands of retail traders.