Discussing the article: "Creating a mean-reversion strategy based on machine learning" - page 9

 

Good day, Maxim. Good afternoon, honoured colleagues.

I have a burning question.

I wanted to add additional functionality to the bot (outputting a position to breakeven and trawl sl), but encountered the impossibility of compiling the source code (I use the standard compiler from the MT5 package).
Even the original source code mean reversion.mq5, attached by the author to the article, does not pass through .
The problem is in the functions OnnxSetInputShape and OnnxSetOutputShape (lines 51, 58, 66, 71). According to the mql5 help, the input data for these functions are three variables: two of the long type and the third of the const ulong type. However, according to the Expert Advisor code, the variables ExtInputShape, ExtInputShape2 and output_shape used as initial variables in the functions under consideration are initialised as const long ( lines 31, 32, 65).

When the data type of the variables is changed to const ulong, the compilation succeeds. However, the bot stops working "in profit", i.e. the implemented trading strategy algorithm is not executed.

Please help in solving this problem. I consider the option with an external compiler in the last place. Is it possible to compile with standard MT5 tools without checking the code correctness?

[Deleted]  
Vladimir Levchenko long type and the third of the const ulong type. However, according to the Expert Advisor code, the variables ExtInputShape, ExtInputShape2 and output_shape used as initial variables in the functions under consideration are initialised as const long ( lines 31, 32, 65).

When the data type of the variables is changed to const ulong, the compilation succeeds. However, the bot stops working "in profit", i.e. the implemented trading strategy algorithm is not executed.

Please help in solving this problem. I consider the option with an external compiler in the last place. Is it possible to compile with standard MT5 tools without checking the code correctness?

Kind, try this option. I don't remember what else I changed besides ulong. Yes, after the update, some ph-iases started to work differently than before.

Write in #define the names of your phases from your include file.
Files:
 
Maxim Dmitrievsky #:

Kind, try this option. I don't remember what else I changed besides ulong. Yes, after the update, some ph-iases started to work differently than before.

In #define, write the names of your phases from your include file.

Good day.

I did it. But, unfortunately, the reason is something else. I am attaching screenshots of the results of your compiled version and the version where variable types are replaced with ulong.

With LONG variables After the change to ULONG.

[Deleted]  
Vladimir Levchenko #:

Good day.

I did. But, unfortunately, the reason is something else. I am attaching screenshots of the results of your compiled version and the version where variable types are replaced with ulong.


Do you use the same type of attributes in the bot as in the training? It happens that you have changed attributes in the python script, but not in the inklulnik.
Because this variant, that I've thrown to you, works fine for me.
Judging by the curve of the graph, the model is not getting the features it was trained on
 
Maxim Dmitrievsky #:
Do you use the same type of attributes in the bot as in the training? It happens that you have changed the attributes in the python script, but not in the inklulnik.
Because this variant, that I've thrown to you, works fine for me.
Judging by the curve of the graph, the model is not getting the features it was trained on

Probably. Because I pull up the model files that were in the initial release of the bot.
But the algorithm of model training is still at the stage of studying and realising. I have no problems with Mql5, but with Python I am still having a hard time making friends with it.

[Deleted]  
Vladimir Levchenko #:

Probably. Because the model files I am pulling up are the ones that were there at the initial release of the bot.
But the algorithm of model training is still at the stage of study and realisation. I have no problems with Mql5, but the friendship with python is still a bit difficult.

Checked, everything works for me. I have attached the files of trained models from the article and the updated bot above.

It is desirable to retrain the models afterwards, because there are demo models attached to the article. When you understand the python script.


 
Maxim Dmitrievsky #:

Checked, everything works for me. Attached the files of trained models from the article and the updated bot above.

It is desirable to retrain the models afterwards, because there are demo models attached to the article. When you understand the python script.


Good day!
Yes, in this release the bot itself compiles and works correctly. But the models need to be retrained. And in general, as I understand, it should be done regularly.
I'm getting to grips with python, but I'm not getting everything yet. I rolled the main release of Rutop on my laptop and updated it to the current version. I installed all necessary packages (pandas, numba, numpy, catboost, scipy, scikit-learn). Quotes downloaded. I put the file of quotes and all scripts in Files folder in the main catalogue of MT5. I have written the paths in the code of the model training script. But something does not go to the result.
I correct the script code in MetaEditore. I try to run the script from there. The process crashes into an error (it doesn't find the bots package python, and the attempt to install it according to the scheme of installing other packages also ends with an error). The same error occurs when running the script through the python console.
Can you advise me in which direction to drill the topic?

Error installing the bots package


Error in script operation

[Deleted]  
Vladimir Levchenko #:
Good day!
Yes, in this release the bot itself compiles and works correctly. But the models need to be retrained. And in general, as I understand, it should be done regularly.
I'm getting to grips with python, but not everything is working so far. I rolled the main release of Rutop on my laptop and updated it to the current version. I installed all necessary packages (pandas, numba, numpy, catboost, scipy, scikit-learn). Quotes downloaded. I put the file of quotes and all scripts in Files folder in the main catalogue of MT5. I have written the paths in the code of the model training script. But something does not go to the result.
I correct the script code in MetaEditore. I try to run the script from there. The process crashes into an error (it doesn't find the bots package python, and the attempt to install it according to the scheme of installing other packages also ends with an error). The same error occurs when running the script through the python console.
Can you advise me in what direction to drill the topic?

Bots is just the root directory (folder) where the modules from the article are located. If the script doesn't see them when importing modules (additional files), then write full paths to the files.

Or throw all these files into the same folder as the main script and do this instead:

Было
from bots.botlibs.labeling_lib import get_labels
from bots.botlibs.tester_lib import test_model
from bots.botlibs.export_lib import export_model_to_ONNX

Стало
from labeling_lib import get_labels
from tester_lib import test_model
from export_lib import export_model_to_ONNX

This can happen if you didn't have PYTHONPATH prescribed when you installed Python. Search the internet to find out how to prescribe it for your system. That is, Python doesn't see the files on the disc.

Or read a basic course on importing modules on the internet.

 
Maxim Dmitrievsky #:

Bots is just a root directory (folder) where modules from the article are located. If the script does not see them when importing modules (additional files), write full paths to the files.

Or throw all these files into the same folder as the main script and do this instead:

This can happen if you didn't have PYTHONPATH prescribed when you installed Python. Search the internet to find out how to prescribe it for your system. That is, python doesn't see the files on the disc.

Or read a basic course on importing modules on the internet.

Good day, Maxim. Thank you. Almost everything is solved. The last question.
There are commented lines (154-182) in the main script for training models. As I understand, these are alternative deal samplers (markups). But I cannot try them. If any of the markers is uncommented (conditionally, lines 154-158) and the original one is commented out (lines 149-153), the script does not start.
What can be the reason, where to look?

Thanks )

[Deleted]  
Vladimir Levchenko #:

Good day, Maxim. Thank you. Almost everything is solved. The last question.
There are commented lines (154-182) in the main script for training models. As I understand, these are alternative deal samplers (markups). But I cannot try them. If any of the markers is uncommented (conditionally, lines 154-158), and the original one is commented (lines 149-153), the script does not start.
What can be the reason, where to look?

Thanks )

Hi, you need logs of what the Python interpreter writes.