Skip to content
All library documents

Wrapping ONNX Trading Models in Reusable MQL5 Classes

Article MQL5 articles

Summary

The article shows how to organize multiple ONNX classifiers in MQL5 using a shared base class and model-specific subclasses. The base class stores the trained symbol and timeframe, checks that an expert advisor is using the matching market, creates and releases the ONNX session, and schedules predictions at new bars. Subclasses prepare each model’s input data, set tensor shapes, and return class predictions, allowing the trading logic to use a common interface.

It then combines three EURUSD daily models with hard or soft voting and describes example tester outcomes, including a more selective unanimous-vote setting. The models were trained on different price inputs using historical MetaQuotes demo data. The reported results are limited to those tests and do not establish future performance; the article explicitly presents the expert advisor as a programming demonstration rather than a live-trading system.

Key ideas

  • A shared base class can centralize ONNX session management and symbol-timeframe checks.
  • Model-specific subclasses can encapsulate input preparation and prediction logic behind a common interface.
  • The example ensemble combines three classifiers using either hard voting or summed class probabilities.
  • The reported trading outcomes are illustrative backtest results and are not evidence of live profitability.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.