Skip to content
All library documents

Training Models in Python and Deploying Them in MQL5 with ONNX

Article MQL5 articles

Summary

The article explains a workflow for training a machine-learning model in Python, exporting it through ONNX, and running it from an MQL5 trading program. Its example is a regression model using open, high, and low prices as inputs and close price as the target. It describes collecting training data in MQL5, preparing separate live inputs without the target, normalizing features, preserving normalization parameters, and matching the model's expected input and output shapes.

The examples show data collection and deployment code, sample terminal output, and an ONNX parameter-size error that illustrates the importance of tensor dimensions. The author also notes that training, testing, and live data must use consistent preprocessing, and that a strategy-tester detail for reading normalization files is not covered. The article is an integration tutorial rather than a trading study: it gives no forecast accuracy, backtest, or evidence that the example model produces a tradable edge.

Key ideas

  • ONNX provides a shared model format for moving a trained model from Python into an MQL5 application.
  • The example uses open, high, and low prices as features and close price as the supervised target.
  • Training and live data must be collected with matching feature definitions and preprocessing.
  • Normalization parameters from training need to be retained and reused for later inputs.
  • The tutorial covers integration mechanics but does not report predictive performance or trading results.

Tags

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