Building a Reproducible MQL5 Machine Learning Pipeline with PCA and ONNX
Summary
The article describes an ML workflow in which Python trains a model while MQL5 prepares its inputs and runs inference through ONNX. It represents observations and features as matrices, then applies normalization and, optionally, principal component analysis (PCA) to reduce redundant dimensions. The central engineering requirement is to reproduce the same feature preparation and transformations in the terminal that were used during training, so the model receives consistent inputs in deployment.
The training example uses a PCA and LSTM workflow, with normalization parameters and PCA transformations calculated during training and then applied in the MQL5 environment. The article also points to the strategy tester for evaluating trading behavior and risk metrics. It explains pipeline construction rather than demonstrating a profitable strategy: no evidence in the supplied text establishes predictive edge, and PCA or an LSTM does not by itself ensure robust out-of-sample performance.
Key ideas
- Representing observations and features as a matrix makes data transformations consistent across the pipeline.
- Normalization and PCA parameters calculated during training need to be reproduced during terminal inference.
- Python is used for model training, while MQL5 prepares inputs and executes the exported ONNX model.
- The example combines PCA-based feature preparation with an LSTM model.
- Strategy testing can examine risk and trading behavior, but the described pipeline does not establish a profitable edge.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.