Skip to content
All library documents

Using an MQL5 DataFrame to Prepare Market Data for Machine Learning

Article MQL5 articles

Summary

The article develops an MQL5 class modeled on Python’s Pandas DataFrame to collect, inspect, transform, and export data for machine learning. It stores tabular data in a matrix and tracks column names separately. Because the implementation holds numeric values as doubles, integer inputs must be converted and string features encoded before insertion. Methods cover adding or replacing columns, reading CSV files, previewing rows, selecting data, and performing time-series transformations.

A market-data collection workflow supplies examples for training and deployment: data prepared in MQL5 is used alongside a Python-trained linear regression model exported in ONNX format, then loaded by an Expert Advisor. The described trading rule buys when the predicted close exceeds the bid and sells when it falls below the ask. The article includes a strategy tester period, but the excerpt provides no detailed performance metrics. Its main caveat is maintaining consistent data structure and values between training and live inference; the class also does not support Pandas’ full range of data types.

Key ideas

  • The custom DataFrame stores tabular values in an MQL5 matrix and keeps column labels separately.
  • The implementation is numeric, so integers need conversion and strings need encoding before use.
  • CSV loading and data inspection methods support preparing datasets inside MQL5.
  • The workflow links MQL5 data collection with Python model training and ONNX deployment.
  • The example trades based on whether a predicted close is above the bid or below the ask.
  • Training and inference data must remain aligned in structure and values.

Tags

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