How to execute MT5 code periodically?

 

Hi All,

I am new to MT5, how can I execute MT5 code periodically?  Say every 4 hours or so?

Any code examples?

Thank you.

TT77

 
you can use a function to detect new H4 candlestick and execute the code once a new candlestick is detected. there are plenty codes on a such topic 
 
TT7749: , how can I execute MT5 code periodically?  Say every 4 hours or so?
  1. Why would you want to? Nothing is changing when the markets are closed.
         How To Ask Questions The Smart Way. (2004)
              Be precise and informative about your problem

  2. For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart), volume is unreliable (miss ticks), Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
              MT4: New candle - MQL4 programming forum #3 (2014)
              MT5: Accessing variables - MQL4 programming forum #3 (2022)

    I disagree with making a new bar function, because it can only be called once per tick (second call returns false). A variable can be tested multiple times.
              Running EA once at the start of each bar - MQL4 programming forum (2011)

 

Ugochukwu Mobi, William Roeder, Thank you for the advice.

 
TT7749:

Hi All,

I am new to MT5, how can I execute MT5 code periodically?  Say every 4 hours or so?

Any code examples?

Thank you.

TT77

code example : here

Candle Closing Time Notify Alarm
Candle Closing Time Notify Alarm
  • www.mql5.com
Notifies you at your specified Chart Time Indicator can be used to set alarm at a specified time on the chart.
Reason: