Download MetaTrader 5

Metatrader 5 - TimeCurrent() function returning old date

To add comments, please log in or register
gr101
196
gr101 2016.05.07 11:59 
Hi,

When I run the following line of code against the EURUSD I get a value of: D'2016.05.05 21:52:41'

datetime timeCurent = TimeCurrent();

However when I open up a chart in Metatrader the last bar is '2016.05.06 23:55'.

As per the TimeCurrent() documentation (https://www.mql5.com/en/docs/dateandtime) for Mql 5 the time current does the following "Returns the last known server time (time of the last quote receipt) in the datetime format"

In the scenario above I have a TimeCurrent() '2016.05.05 21:52:41' that is two days before the last date I can see on the chart '2016.05.06 23:55'.

Any ideas what's going on here?

Documentation on MQL5: Date and Time
Documentation on MQL5: Date and Time
  • www.mql5.com
Date and Time - Reference on algorithmic/automated trading language for MetaTrader 5
Alain Verleyen
Moderator
31134
Alain Verleyen 2016.05.07 12:22  
The market is closed, so if your platform was not open when it closed, you will have a datetime in the past. It's not linked to the bar time.
gr101
196
gr101 2016.05.07 16:41  

Aha!

That makes sense.

Here's what I did.

Thurs: Shut down metatrader

Sat: Opened it up and it must have downloaded the history but kept TimeCurrent() from Thurs.

Thanks :)

To add comments, please log in or register