What is ONNX in the context of trading?
ONNX (Open Neural Network Exchange) is an open format for AI models that lets you create, train and deploy machine-learning models for predicting financial markets. In trading, ONNX is used to run predictive models directly inside platforms such as MetaTrader 5.
Since January 2026, MetaTrader 5 Build 5572 has added CUDA support for GPU, lazy-loading of the ONNX library and multi-GPU support — making AI-based trading bots faster and more accessible than ever.
💡 Recommended resource
If you want pre-trained ONNX models ready to install in MT5, see our AI bots guide, with models validated by backtesting and integrated risk management for forex and binary options.
How does an ONNX bot work in MT5?
The workflow of an ONNX bot has three phases:
- Training: you gather historical price data, train a prediction model (neural networks, LSTM, transformers) in Python with TensorFlow or PyTorch, and export the model to the ONNX format
- Integration: you load the .onnx file into MetaTrader 5 as an Expert Advisor resource. The OnnxCreate(), OnnxRun() and OnnxRelease() functions in MQL5 let you run inference inside the EA
- Execution: the EA feeds market data to the ONNX model, receives predictions (price direction, probability, volatility) and executes trades based on those signals
ONNX Runtime: performance and resources
ONNX Runtime uses between 30 and 100 MB of RAM, far less than the full TensorFlow (1.7 to 4.8 GB). This means you can run AI models on a basic VPS for $5-$15/month. With the CUDA support in Build 5572, you can accelerate inference with a dedicated GPU.
Advantages of ONNX over traditional bots
- Data-driven prediction: instead of fixed rules ("buy when RSI < 30"), the model learns complex patterns from historical data
- Adaptability: you can periodically retrain the model with new data
- Universality: an ONNX model trained in Python works in MT5, cTrader or any platform with ONNX support
- Speed: inference in milliseconds, ideal for scalping and high-frequency trading
⚠️ The reality of machine learning in trading
Applying ML to trading is extremely hard. Markets are non-stationary, overfitting is constant, and a model that works in backtesting can fail live. Never trust a model blindly without rigorous validation.
ONNX for binary options
In binary options, where you only need to predict the price direction (up or down) over a fixed period, ONNX is particularly useful. The model is trained as a binary classifier (call/put) with associated probabilities.
The brokers that best support automation with ONNX bots:
- Deriv — a complete automation API, no-code DBot, 24/7 synthetic markets
- IQ Option — an award-winning platform, CySEC regulation, a free demo for backtesting
- Quotex — payouts up to 98%, a fast interface
⚠️ Risk warning
Trading binary options carries significant risk. The majority of traders lose money. This site contains affiliate links.