Regional notice (EN-ZA): South Africa readers: FSCA regulates retail FX. Crypto exchanges require FSP licensing as of 2023. Most US-based prop firms accept ZA residents.
Home/ONNX + MT5
Pillar 01 · the core

ONNX in MetaTrader 5: the working playbook.

Everything you need to load, run, and ship an ONNX model inside an MQL5 Expert Advisor — the right way. Build 5572 brought native CUDA acceleration, eight selectable GPU devices, and a profiling JSON. This is the silo that documents all of it, with code that compiles and error messages that get fixed.

// what you'll learn

The MQL5 ONNX API, demystified.

The official MetaQuotes docs tell you the function signatures. They don't tell you which flag changed in Build 5572, why OnnxRun silently falls back to CPU, or how to read the new profiling JSON. We do.

// the loop

The flag cheat-sheet (Build 5572).

If you remember nothing else from this site, remember these.

ENUM_ONNX_FLAGS — Build 5572
// CPU/GPU control ONNX_USE_CPU_ONLY // force CPU (replaces removed ONNX_CUDA_DISABLE) ONNX_GPU_DEVICE_0 ... ONNX_GPU_DEVICE_7 // pick a CUDA device // Logging (ONNX_DEBUG_LOGS is deprecated) ONNX_LOGLEVEL_VERBOSE // every log line ONNX_LOGLEVEL_WARNING // warnings + errors ONNX_LOGLEVEL_ERROR // errors only // Profiling ONNX_ENABLE_PROFILING // dumps JSON to /MQL5/Files/OnnxProfileReports/ // Runtime ONNX_NO_CONVERSION // skip auto type conversion (faster if types match)

One step deeper: pick where the model runs.

Local workstation, GPU cloud, or forex VPS? They aren't interchangeable — one of them can't run CUDA at all.

Compare the three options →