You can't embed "Pyhton" into your MQL5 code. The Python integration is for externally accessing MetaTrader 5 only.
You can't embed "Pyhton" into your MQL5 code. The Python integration is for externally accessing MetaTrader 5 only.
If I am informed correctly, the integration is for scripts only and you cannot build experts - there isn't even an OnTick-Function (need to build a while-true-loop and ask for data every x time-periods?) and you cannot test it with the strategy tester, which makes the usability horrible.
In C++ it is possible to embed python so I hoped it was possible in mql5 too...
Can I do something like embedding my python in a C++-Class, integrate this C++ Class in a .dll and use it through the dll?
As I stated, it is for external access only! Not for event driven interaction. However, even with those limitations, you can still develop automation equivalent to an EA, for strategies that are not so critical with regard to tick events and can easily work on a timed based interaction.
It makes no sense to go to so much trouble to interchange between three languages, MQL, C++, and Python. It's going to be bloated and inefficient. Take the time to do it in pure MQL5 with the added benefit of being more concise and efficient and have much less hassle.
As I stated, it is for external access only! Not for event driven interaction. However, even with those limitations, you can still develop automation equivalent to an EA, for strategies that are not so critical with regard to tick events and can easily work on a timed based interaction.
It makes no sense to go to so much trouble to interchange between three languages, MQL, C++, and Python. It's going to be bloated and inefficient. Take the time to do it in pure MQL5 with the added benefit of being more concise and efficient and have much less hassle.
I have read carefully, the need to invoke python functionality in MQL5 exists, because python has rare and complex functions (think of econometrics), not MQL5. There would be Alglib, but there is no decent documentation, which instead is richly explained in the python libraries. Returning to the integration, my conclusion is that it is only possible by compiling the python libraries into DLLs, and calling the DLL inside the indicators or EAs. Do you have any examples on the net using DLLs in MQL5 code?
I have no examples myself, but you can search the Articles section for examples of how to write and call DLLs from MQL.
However, most of them are for C/C++ or C#. I think there is also a Delphi example, but I don't believe there are any examples for Python.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I have a complete python-project that calculates signals for a history of data. For simplicity lets say I have a class like that:
Now I would like to create an instance of this class in my OnInit and call next in OnTick.
Is there a way to do something like that (libraries / dlls maybe)? I do need to include a class, not just a function. Could you give me an example on how to do it or a link to a tutorial?
Thank you!