How to get the value of current hour?

 

I found this remark for Hour(): The value returned from Hour() will not change within the time of the program execution and it's the time of program start.

Then please help tell how to get the latest hour of the MT4 server! Thanks and happy new year! 

 

You misunderstood what you have read.

The time isn't changed just like Bid and Ask isn't changed. So if the market is closed the time is the time of the last tick your EA has got: the last tick of the (now closed) session!

As alternative you have only TimeLocal or TimeGMT() which both are taken from you local pc (mind the various time shifts!!) - so, nothing to work with in the strategy tester.
 

Hour() will work to get the latest hour value from the server.  Here is a link you will find helpful explanation.

But remember, as gooly suggested, Hour() will return the latest hour value that the server recognizes that the market is open...so that is the hour value of the latest tick (or the last tick of the open market).  

 

Dear Gooly and Thirteen, thank you both very much!

So, may I understand the value gets from Hour() is the server time of the latest-tick and that works same between testing and live trade?

 

just for double confirming, is my understanding correct?

 may I understand the value gets from Hour() is the server time of the latest-tick and that works same between testing and live trade? 

 
jollydragon:

just for double confirming, is my understanding correct?

 may I understand the value gets from Hour() is the server time of the latest-tick and that works same between testing and live trade? 

You have to understand that we do not always know the up to date answers as so many things have changed lately.

This is so easy to check yourself by putting Hour() in Comment() and checking in visual mode

 
thanks for the good suggestion:
GumRai:

You have to understand that we do not always know the up to date answers as so many things have changed lately.

This is so easy to check yourself by putting Hour() in Comment() and checking in visual mode

Reason: