Questions on "ONNX.Price.Prediction" Shared Project

 

The MQL5 documentation -> ONNX section -> "Creating Model" article offers the "ONNX.Price.Prediction" shared project for an example on how to use Machine Learning in MetaTrader5.

I tried running the project, but faced some problems:

- I noticed the code doesn't run with the library versions described in the docs (the docs instruct "pip install --upgrade tensorflow", etc.). tf2onnx library only support tensorflow==2.15.0 and below currently. And in order to install tensorflow==2.15.0, the python version shouldn't be above 3.9. I ran the code using python 3.9 and tensorflow==2.15.0.

- There seem to be three versions of the code inside the folder. Here is the project structure:

│   ONNX.Price.Prediction.mq5
│   ONNX.Price.Prediction.mqproj
│   ONNX.Price.Prediction.Test.mq5
│   ONNX.Price.Prediction.Test2.mq5
│   ONNX.Price.Prediction.Test3.mq5
│   ONNX.Price.Prediction2.mq5
│   ONNX.Price.Prediction3.mq5
└───Python
    │   model.onnx
    │   model2.onnx
    │   model2_n0.onnx
    │   model2_n0_m.onnx
    │   model2_n0_m_20.onnx
    │   model2_n1.onnx
    │   model2_n1_m.onnx
    │   model2_n1_m_20.onnx
    │   model2_n2.onnx
    │   model2_n2_m_20.onnx
    │   model3.onnx
    │   model_n2_m.onnx
    │   PricePrediction.py
    │   PricePrediction2.py
    │   PricePrediction3.py
    │   PricePredictionTraining.py
    │   PricePredictionTraining2.py
    │   PricePredictionTraining3.py
    │
    └───godvisnPredictiveTraining
             godvisnPredictiveTraining.mq5
             godvisnPredictiveTraining.mqproj

It's not noted what is their difference and which one of the three versions is the better one.

- In the "PricePrediction.py", when we get the final prediction at the end of the code, there is:

y_pred = np.round(y_pred_norm.flatten() * s[:, 0, 3] + m[:, 0, 3], decimals=5)

However, in "PricePrediction3.py", there is:

# y_pred = np.round(y_pred_norm.flatten() * ((s[:, 0, 1] - s[:, 0, 0]) - (s[:, 0, 0] - s[:, 0, 2])) + ((m[:, 0, 1] - m[:, 0, 0]) - (m[:, 0, 0] - m[:, 0, 2])), decimals=5)
y_pred = np.round(y_pred_norm.flatten(), decimals=5)

I'm confused on which one is correct. I tried "ONNX.Price.Prediction.Test3.mq5" but I got unexpected price predictions, sometimes negative values. Could it be that the "y_pred" is calculated wrongly?

- Are there other similar recommended projects? I need a simple yet standard code with basic Machine Learning implementation.

Documentation on MQL5: ONNX models / Creating a Model
Documentation on MQL5: ONNX models / Creating a Model
  • www.mql5.com
Multiple methods are available to obtain a ready model in the ONNX format. The popular ONNX Model Zoo library contains several pre-trained ONNX...