You attached the EA, the Experts log spat out this, and the EA refused to trade:
ERROR 5800 is MQL5's generic "I tried to create an ONNX session and it didn't work." The message itself is unhelpful — it can mean six different things. The good news: each cause has a fast, specific diagnosis. Walk through these in order.
What's in this article
Cause 1: file path is wrong
The most common cause, by a wide margin. OnnxCreate takes a path relative to <Terminal Data Folder>\MQL5\Files\, not relative to the EA, not absolute. Two failure modes:
- You passed an absolute path like
"C:\models\eurusd.onnx"— MQL5 won't accept it. - You passed a path that's correct on your dev machine but wrong on the deployment VPS (e.g. the
modelssubdirectory wasn't copied).
Diagnosis
In MetaTrader 5, click File → Open Data Folder. Navigate into MQL5\Files\. Confirm your .onnx file is exactly where you said. If your code says "models\eurusd.onnx", the file should be at MQL5\Files\models\eurusd.onnx.
Fix
Two clean approaches:
- Match the path. Move the file to the location your code expects, or change the code.
- Embed as a resource. The cleanest production fix — use
#resourceandOnnxCreateFromBuffer. The model travels inside the.ex5, there's no separate file to lose. See the OnnxCreate reference.
Cause 2: invalid or corrupt .onnx file
The file exists at the right path, but it's not a valid ONNX model. Two scenarios:
- The export from Python silently failed (you got the file, but it's incomplete or wrong format).
- The file got corrupted during transfer (truncated upload, etc).
Diagnosis
Open the file in Netron — the free ONNX visualizer. Drag the .onnx into the browser tab. If Netron renders the graph, the file is a valid ONNX model. If Netron throws an error, the file is broken — re-export from Python.
If you can't reach Netron, a quick sanity check in Python:
If check_model raises, the file is invalid. Re-export.
Cause 3: opset version unsupported
ONNX models are tied to an opset version — effectively, "which version of the ONNX op spec was I built against." Recent PyTorch defaults to opset 18 or higher; the ONNX Runtime in MT5 supports up to opset 19 in Build 5572. If you exported with opset 20+ (using PyTorch nightlies or experimental features), the runtime can't load it.
Diagnosis
The Python snippet above prints the opset. Or in Netron, click on the model background — the right panel shows opset_import.
Fix
Re-export with opset_version=17 explicitly. This is the safe default for MT5 in 2026:
More on opset selection in the opset guide.
Cause 4: GPU initialization failed silently
Sometimes the file is valid and the path is right, but the GPU initialization fails in a way that prevents the whole session from loading — and the only visible symptom is ERROR 5800.
The classic case is CUBLAS_STATUS_ARCH_MISMATCH: GPU below Turing, cuBLAS refuses to initialize, the whole session creation fails, and you see ERROR 5800 in the log (with the underlying cuBLAS error a few lines above).
Diagnosis
Scroll up in the Experts log from the ERROR 5800 line. Look for any line containing CUBLAS, CUDA, or cublasCreate. If there's one, the failure is GPU-related — not file-related.
Fix
Force CPU with ONNX_USE_CPU_ONLY:
If the session now loads, the cause was GPU. See the CUBLAS fix for the longer story.
Cause 5: file permission / Tester sandbox
The Strategy Tester runs EAs in a sandboxed agent process with its own filesystem view. A file in your live MQL5\Files\ may not be visible to the Tester.
Diagnosis
Does the EA work on a live chart but fail with ERROR 5800 only in the Strategy Tester? It's the sandbox.
Fix
The cleanest fix is to embed the model with #resource — embedded resources travel inside the compiled .ex5 and work in both live and Tester. If you must keep the model as an external file, also place a copy in MQL5\Tester\Files\ (the Tester's separate file root).
Cause 6: ONNX runtime didn't download
Build 5572 changed the ONNX Runtime DLL from "bundled with MT5" to "downloaded on first use." On a brand-new MT5 install, the very first OnnxCreate call may stall while the runtime downloads — or fail entirely if the machine has no internet or a firewall blocks the download.
Diagnosis
Is this a fresh MT5 install? Has any ONNX function ever run on this machine before? If no to both: the runtime isn't on disk yet.
Fix
- Confirm the machine has outbound HTTPS access. Some VPS providers firewall everything not on a whitelist — check with your provider.
- Restart MT5 and let it sit for 60 seconds before attaching the EA. The first download can take 5–20 seconds.
- If still failing, manually check the
Terminal\Bases\Default\directory inside the MT5 data folder — the ONNX runtime DLL should be there. If not, contact MetaQuotes or check the platform logs.
The checklist
When ERROR 5800 appears, walk through these in 5 minutes:
- Is the file where you said it is? (open the data folder, look)
- Does Netron open it? (if not, re-export)
- Is the opset 17 or lower? (re-export if higher)
- Is there a CUBLAS line above the 5800? (force CPU)
- Is this in the Strategy Tester only? (embed as resource)
- Is this a fresh MT5 install? (let the runtime download)