TimeCurrent() of a non current chart

 
Hi guys. Since the TimeCurrent() function returns the time of the last known tick (of the current chart) in OnTick() handler, how can I return the time of the last known tick of a non-current chart? Of course, we all know that the ticks of different charts/instruments don't appear at the same time.
 
macpee:
Hi guys. Since the TimeCurrent() function returns the time of the last known tick (of the current chart), how can I return the time of the last known tick of a non-current chart? Of course, we all know that the ticks of different charts/instruments don't appear at the same time.
TimeCurrent

TimeCurrent

Returns the last known server time, time of the last quote receipt for one of the symbols selected in the "Market Watch" window. In the OnTick() handler, this function returns the time of the received handled tick. In other cases (for example, call in handlers OnInit(), OnDeinit(), OnTimer() and so on) this is the time of the last quote receipt for any symbol available in the "Market Watch" window, the time shown in the title of this window. The time value is formed on a trade server and does not depend on the time settings on your computer


I don't think that there is anyway to get Timecurrent() updated while OnTick() is being executed. Only in the other functions.

 
macpee:
Hi guys. Since the TimeCurrent() function returns the time of the last known tick (of the current chart) in OnTick() handler, how can I return the time of the last known tick of a non-current chart? Of course, we all know that the ticks of different charts/instruments don't appear at the same time.

Isn't it just this, where sym is whatever symbol you want the current time for?

datetime ticktime=MarketInfo(sym,MODE_TIME)
 
andrew 2022 #:

Isn't it just this, where sym is whatever symbol you want the current time for?

Wow! Seems to be what I need. Thanks.

 
andrew 2022 #:

Isn't it just this, where sym is whatever symbol you want the current time for?

datetime ticktime=MarketInfo(sym,MODE_TIME)

I must admit that I have never even noticed that before.

Learn something new every day :)

 
andrew 2022 #: Isn't it just this, where sym is whatever symbol you want the current time for?
Or make it explicit
datetime TimeCurrent(string symbol){ return MarketInfo(symbol, MODE_TIME); }
 
macpee #:

Wow! Seems to be what I need. Thanks.

But I don't think you can get the latest tick time of the other chart until you get a tick on the parent/host chart, unless you used a timer event.

Reason: