Python for mql5 [How to do circle by new tick?]

 
For now I use this construction:

def AnalyzeAndAutoOrder():
    time.sleep(5)
    while(True):
          ..... any operations ....
        # Sleep ...
        time.sleep(0.250)
 
AutoTrade = threading.Thread(target=AnalyzeAndAutoOrder, daemon=True, args=())
AutoTrade.start()

But I need to do condition for while to repeat only after get new tick (equal mt5) ... Maybe anybody know how do it for better works?
 
sergey087:
For now I use this construction:


But I need to do condition for while to repeat only after get new tick (equal mt5) ... Maybe anybody know how do it for better works?

Hello, how are you?


I am not sure if I understood it correctly, but you could try to check the last tick time. You still need to check each tick, but the heavy calculation made inside ..... any operations .... will happen only in a new tick. It may not be equal to MQL5, but it might work.

I have this solution:

time = 0
while True:

    tick = Tick(trade.symbol)

    if tick.time_msc != time:


       ..... any operations ....
    

    time = tick.time_msc
It checks the time of the last tick and it stores that information, if it runs the code and the time is the same, it skips the heavy calculation.

The solution I made is a little bit old, I believe that by the end of April I will be able to release a better code with different features.

If you are interested, you can check more about my updates here.

Mql5-Python-Integration/example.py at master · Joaopeuko/Mql5-Python-Integration
Mql5-Python-Integration/example.py at master · Joaopeuko/Mql5-Python-Integration
  • Joaopeuko
  • github.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 
Joao Paulo Euko #:

Hello, how are you?


I am not sure if I understood it correctly, but you could try to check the last tick time. You still need to check each tick, but the heavy calculation made inside ..... any operations .... will happen only in a new tick. It may not be equal to MQL5, but it might work.

I have this solution:

It checks the time of the last tick and it stores that information, if it runs the code and the time is the same, it skips the heavy calculation.

The solution I made is a little bit old, I believe that by the end of April I will be able to release a better code with different features.

If you are interested, you can check more about my updates here.

Thanks, This is only one idea that I was think and you are get this too :) I not sure, but I think that integration API need "event" that will be work if market is change ... and current method is really one that better, because I can skip many iteration without changes.