It's possible but not necessarily the best approach. Given that most Machine Learning libraries for Python are actually written in C/C++ with a Python wrapper, you might as well directly access the pure libraries via a DLL calls for a much more direct and efficient solution. Going through Python would be slow, inefficient and just be a kludge.
Seems like you'll need to create both ends . Trading simulation in python and ML in mql5 (at least the feed forward part if NN), because you will need testing accuracy during training and you will need the "brain" functions of whatever you trained in mql5.
There is a saying in Greece
"We ate the whole cow but we are debating eating the tail"
It's possible but not necessarily the best approach. Given that most Machine Learning libraries for Python are actually written in C/C++ with a Python wrapper, you might as well directly access the pure libraries via a DLL calls for a much more direct and efficient solution. Going through Python would be slow, inefficient and just be a kludge.
There are several Articles about Machine Learning and Neural Networks here on the website.
There are also several related forum topics too, and a few related CodeBase publications.
So, run a Search here on the website and do some reading.
Some searches based on following keywords:
Seems like you'll need to create both ends . Trading simulation in python and ML in mql5 (at least the feed forward part if NN), because you will need testing accuracy during training and you will need the "brain" functions of whatever you trained in mql5.
There is a saying in Greece
"We ate the whole cow but we are debating eating the tail"
Because MetaTrader only offers back-testing for MQL5 EAs and not for Python code.
So if your Python code is stand-alone or needs to train on its own without the MQL5 front-end, you would then need to create your own trading simulation functionality for the python components.
This is probably what @Lorentzos Roussos meant by his comments.
Because MetaTrader only offers back-testing for MQL5 EAs and not for Python code.
So if your Python code is stand-alone or needs to train on its own without the MQL5 front-end, you would then need to create your own trading simulation functionality for the python components.
This is probably what @Lorentzos Roussos meant by his comments.
Always on point ++
Im sorry for my ignorance but I'm quite confused with your reasoning as to why I would need " Trading simulation in python and ML in mql5".
Its not ignorance , i'm just saying your "model" will need to evaluate itself somehow . So you will either export all the signals from mt5 and then optimize with the field of signals on python (or anything else . You can do this now for instance with excel's built in genetic algorithm) , or , you will export the price feed and do calculations (including indicators) internally (in python).
*The advantage to exporting all the signals is you are not limited to trading rules as you would be in the MT5 tester , you can evaluate all the signals but then , when you move from concept to ea you need to take the "trading rules" into account.
Then , assuming your trained model is ready ,if its a neural net it will have nodes .These nodes will have a configuration , activation functions , weights biases ,dropouts etc.
So you either feed data to python , the model predicts , returns data to mt5 or you "transfer" the "brains" to the ea directly .
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Is my idea feasible? If so what gotchas do I need to lookout for? Is this even the best idea or should i just completely write everything in Python?
A quick background check about me: I already know how to write bots in MQL5. I have used python before but for a completely different scenario (e.g. web scraping, data engineering, etc.) and not trading.