Discussing the article: "Numerical Fidelity Under Fire: Benchmarking Native MQL5, ONNX Runtime, and ALGLIB"

Check out the new article: Numerical Fidelity Under Fire: Benchmarking Native MQL5, ONNX Runtime, and ALGLIB.

This article benchmarks one MLP forward pass implemented three ways in MQL5: native code, ALGLIB, and ONNX Runtime. We quantify numerical fidelity versus a float64 ground truth and execution latency (mean/percentiles), then outline practical criteria and a ready‑to‑use harness to help you choose and integrate the right engine in an EA.

Most of us treat math libraries as interchangeable. A dot product is a dot product, so it shouldn't matter whether it runs through MQL5's matrix types, the bundled ALGLIB port, or ONNX Runtime. This article tests that assumption with one small network and shows where it holds and where it breaks: two of the three engines agree with a float64 reference to machine precision, and the third shows measurable degradation in both accuracy and time.

I kept the setup narrow. I take a trained multilayer perceptron (8 inputs, hidden layers of 16 and 8 units with ReLU, one linear output) and run the identical forward pass through native matrix<double> and vector<double> code, through ALGLIB's CMatrixDouble, and through ONNX Runtime via OnnxRun(). Same weights, same inputs, three execution paths. Then I measure the two things that matter inside a live EA: how far each engine drifts from a float64 ground truth computed in Python, and how many microseconds each one burns per call.

Nine files make up the project: a Python export script, three shared includes, three engine includes, the benchmark EA and an on-chart monitor indicator. Below, I describe each file: what it does, how it works, and why it is structured that way. You can then reuse the harness in your own project with a different model.

Scope note: this is a computation benchmark, not a trading strategy. There is no entry or exit logic anywhere in the project. The Expert Advisor is a diagnostic harness that runs the same inference three ways and logs the results, so the article makes no performance claim about any strategy. The lessons apply to anything you'd normally compute inline: recursive indicators, regime filters, ML inference, risk sizing formulas.

Author: Olamide Daniel Adebayo