Every ONNX model carries an opset version — the version of the ONNX operator spec it was built against. Newer opsets add operators and improve existing ones, but consuming runtimes have to catch up. Use opset 17 for any model you export today for MetaTrader 5 use. The reasoning, the compatibility matrix, and the upgrade path are below.
The recommendation
Pin opset to 17 in your export call. It's the highest version that's broadly supported by MQL5 Build 5572's ONNX Runtime while still supporting all the modern ops you actually need (transformer attention, LayerNorm fused, etc.).
Why not higher?
Higher opsets exist (18, 19, 20+ as of 2026). The problem is the consuming end — MT5's bundled ONNX Runtime may not yet have full coverage of the newer ops. Symptoms of opset-too-high:
OnnxCreatefails with a generic error 5800 (see the ERROR 5800 guide).- The model loads but specific operators throw at inference time.
- Silent CPU fallback — an op that should run on CUDA can't, because the CUDA provider's coverage of that opset is incomplete.
Opset 17 (released October 2022) is mature, broadly supported, and covers everything retail trading needs.
Why not lower?
Pre-17 opsets miss useful operators. Specifically:
- Opset 16 and earlier: no
LayerNormalizationas a fused op — falls back to several primitive ops, which the runtime may schedule less efficiently. - Opset 14 and earlier: several attention-mechanism ops are missing or limited. If you have a transformer, you want at least opset 15.
If you're stuck supporting an ancient consumer for some reason, opset 14 is the lowest you'd realistically target. But for MT5, there's no reason to go below 17.
Checking the opset of an existing model
Or in Netron: click on the empty graph background, look at the right panel for opset_import.
Re-converting a model to a different opset
If you have a model that's at opset 20 and you need opset 17, the cleanest fix is to re-export from the original training code. If you don't have the original code, onnx.version_converter can sometimes down-convert:
This works for many graphs but not all — some ops in higher opsets have no direct equivalent in 17, and the converter will refuse. The reliable answer is always to re-export from training code.