Updated for MetaTrader 5 · Build 5572 · Jan 2026

Run ONNX models in MetaTrader 5, on the GPU.

The deep, accurate playbook for traders who already have a model in Python and just need it to run — fast — inside an Expert Advisor. Export from PyTorch & Keras, wire up OnnxRun, force CUDA the right way, and fix the errors nobody else documents.

PyTorchTensorFlow / KerasONNX RuntimeCUDAMQL5tf2onnxLightGBMNetronStrategy Tester PyTorchTensorFlow / KerasONNX RuntimeCUDAMQL5tf2onnxLightGBMNetronStrategy Tester
0
MT5 build with native CUDA ONNX
Turing+
GPU architectures supported
1 GB
max embedded ONNX model size
0×
selectable GPU devices (0–7)
EURUSD_onnx_ea.mq5 — MetaEditor
// load the model embedded as a resource ExtHandle = OnnxCreateFromBuffer(ExtModel, ONNX_DEFAULT); // batch dim is undefined in the .onnx — fix it before OnnxRun OnnxSetInputShape(ExtHandle, 0, input_shape); // {1,120,1} OnnxRun(ExtHandle, ONNX_NO_CONVERSION, input, output); // -- runtime log ------------------------------ ONNX: CUDAExecutionProvider selected · device 0 x pre-Turing GPU? -> CUBLAS_STATUS_ARCH_MISMATCH
// the real workflow

Train in Python. Run in MQL5. We cover every step.

No hand-waving. The actual path from a trained model to a live Expert Advisor — including the parts that break.

01

Train

Build your LSTM, CNN-LSTM or gradient-boosted model in Python on GPU.

PyTorch · Keras · LightGBM
02

Export

Convert to ONNX with the right opset and static sequence length to avoid export failures.

torch.onnx · tf2onnx · opset 17
03

Integrate

Embed the model, set input/output shapes, and run it inside your EA on CPU or CUDA.

OnnxCreate · OnnxRun
04

Backtest

Validate in the Strategy Tester — and fix the normalization bug that ruins results.

Strategy Tester
// the article that converts

The misconception worth a thousand clicks.

! most-searched, most-wrong

"Forex VPS with GPU" doesn't exist.

Forex VPS are sold on network proximity to the broker's matching engine — Equinix NY4, LD4, TY3. They are CPU-only. CUDA ONNX inference needs a physical NVIDIA GPU: a local workstation or GPU cloud. We say it plainly, then point you to what actually works.

Read the breakdown →
Low order latencyforex VPS ✓
Near broker engineforex VPS ✓
CUDA GPU onboardforex VPS ×
ONNX inferenceGPU cloud ✓
// run your model somewhere real

GPU compute that handles ONNX inference.

Independent picks for training and running models. Every link is tracked so the guides stay honest about what people actually choose.

Affiliate disclosure: some links above are affiliate links. If you sign up through them we may earn a commission, at no extra cost to you. Recommendations are independent — see our disclosure page.

Get the new tutorials before anyone ranks for them.

One email when a new ONNX-in-MT5 guide drops — error fixes, export workflows, infrastructure breakdowns. No spam.