MT4 Freezing during loop

 
Is there an efficient way to exit loop? I can't relay on ticks, i have to check database every second or 2, tick sometimes have long pause. When i do infinite loop, MT4 is difficult to shut down. Can anyone help?
 
No loop at all. Use OnTick to process ticks, use OnTimer to process time based things like your database check. Start using the new Event Handling Functions
 
whroeder1:
No loop at all. Use OnTick to process ticks, use OnTimer to process time based things like your database check. Start using the new Event Handling Functions

OnTimer() works perfect! Thanks!

Reason: