Joaopeuko / Mql5-Python-Integration

I created this library to streamline the process of developing an Expert Advisor in MQL5. While MQL5 development can be complex, the same task is more straightforward in Python.
https://github.com/Joaopeuko/Mql5-Python-Integration
MIT License
145 stars 44 forks source link

How to handle Backtest and Events #3

Closed i3130002 closed 3 years ago

i3130002 commented 3 years ago

By the way, thanks for sharing. Most people tend not to share :heart:

Joaopeuko commented 3 years ago

Hi i3130002, thank you for your message.

Unfortunately, it is not possible yet to use python code on their strategy tester. However, I do have planned to build one strategy tester to help python coders to check how well their strategies are working, but I do not know when I will be able to do it.

To handle events I use a while loop that calls the MT5 API that returns the most recent tick. I use "time" to check the last tick time, and if it is different from the previous tick, it is a new tick and I have the event handler.

time = 0
    while True:

     # Business logic.

     time = tick.time_msc

If you prefer, it is possible to use a timer to call the functions inside the while over a fixed time.

If you have any other questions I am always glad to help.

Thank you.