Get the current hour

 

Hi 

In MT4 you could use Hour() to give you the current hour of the day.

How does someone do that within MT5?

I need to send a notification each day at the same hour of the day.


Thanks

 
ComputerSange:

Hi 

In MT4 you could use Hour() to give you the current hour of the day.

How does someone do that within MT5?

I need to send a notification each day at the same hour of the day.


Thanks

I have just written about this and other time stuff: https://www.mql5.com/en/articles/9926:

#define HoD(t) ((int)(((t)%86400)/3600))  //Hour of Day: 2018.02.03 17:55 => 17
Dealing with Time Part 1: The Basics
Dealing with Time Part 1: The Basics
  • www.mql5.com
Functions and code snippets that simplify and clarify the handling of time, broker offset, and the changes to summer or winter time. Accurate timing may be a crucial element in trading. At the current hour, is the stock exchange in London or New York already open or not yet open, when does the trading time for Forex trading start and end? For a trader who trades manually and live, this is not a big problem.
 
ComputerSange: How does someone do that within MT5?

Migrating from MQL4 to MQL5 - MQL5 Articles № 11

 
Carl Schreiber #:

I have just written about this and other time stuff: https://www.mql5.com/en/articles/9926:

Hi Carl

Thank you for your reply - great article - thanks.

 

Hi William

Thank you for the link - very handy.


I have gone with this which works well - 

int CurrentHour()
  {
   MqlDateTime tm;
   TimeCurrent(tm);
   return(tm.hour);
  }
// Returns the hour (0,1,2,..23) of the last known server time by the moment of the program start