Download MetaTrader 5
To add comments, please log in or register
Follow the news. View our company's official channel!
moonsboy
889
moonsboy 2014.12.26 10:04 

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! 

Carl Schreiber
5927
Carl Schreiber 2014.12.26 10:24  

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.
GreenMoney
379
GreenMoney 2014.12.26 17:01  

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).  

moonsboy
889
moonsboy 2014.12.27 00:03  

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?

moonsboy
889
moonsboy 2014.12.29 08:23  

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? 

Keith Watford
Moderator
7869
Keith Watford 2014.12.29 11:36  
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

moonsboy
889
moonsboy 2014.12.30 01:48  
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

/
To add comments, please log in or register