Skip to content
All library documents

Exporting a Torch Time-Series Model to ONNX for EA Inference

Article MQL5 articles

Summary

This article explains a workflow for deploying a trained Torch time-series forecasting model in a MetaTrader 5 Expert Advisor using ONNX. It covers switching the model into inference mode, collecting and naming its inputs and outputs, exporting it, then loading the exported model in an ONNX runtime to compare predictions on matched input data. The EA section describes preparing the model's expected data format, running inference within MQL5, and using the forecast output to choose a trade direction.

The example reports close agreement between Torch and ONNX outputs for one inference comparison. That checks the conversion path for the sample, but it does not show that the forecasts are accurate or that the trading rule is profitable. The author notes that unsupported ONNX operators can prevent conversion or execution and that the example EA is basic and should not be used casually for real trading. The article presents deployment and backtesting mechanics, not evidence of a validated trading edge.

Key ideas

  • A Torch forecasting model can be exported to ONNX and run for inference inside an MQL5 EA.
  • Matching input names, structures, and data formats is necessary to compare the original and exported models.
  • The article checks conversion by comparing Torch and ONNX outputs on an example input.
  • ONNX compatibility is limited by the operators supported by the target runtime.
  • Agreement between runtimes does not establish forecast accuracy or trading profitability.

Tags

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