Download MetaTrader 5
To add comments, please log in or register
MQL5 Cloud Network speeds up calculations. Try it!
Drazen Penic
2403
Drazen Penic 2014.06.18 15:24 

From the TimeCurrent() help:

"Returns the last known server time, time of the last quote receipt for one of the symbols selected in the "Market Watch" window. "

If I understood correctly, I cannot get current time on the broker's server when market is closed.

 

I would like to calculate time difference between  local time and broker server time, but if market is closed then I don't know how old is TimeCurrent() information. 

Is there any way to get this information when market is closed? 

Boeing747
241
Boeing747 2014.06.18 15:57  
drazen64:

From the TimeCurrent() help:

"Returns the last known server time, time of the last quote receipt for one of the symbols selected in the "Market Watch" window. "

If I understood correctly, I cannot get current time on the broker's server when market is closed.

 

I would like to calculate time difference between  local time and broker server time, but if market is closed then I don't know how old is TimeCurrent() information. 

Is there any way to get this information when market is closed? 

 

There is the local time, or time of the computer -TimeLocal(). Remember the difference TimeLocal()-TimeCurrent() and use this difference for the calculating  of the TimeCurrent() in weekend 
whroeder1
13590
whroeder1 2014.06.18 16:05  
drazen64:
I cannot get current time on the broker's server when market is closed.

I would like to calculate time difference between local time and broker server time, but if market is closed then I don't know how old is TimeCurrent() information.

  1. Correct. Since the market is closed, you don't get ticks, and your EA isn't running.
  2. If you've written the EA to not return from OnTick() then you must remember how old it is.
    Just typed. Not compiled or tested.
    void OnTick{
      while(!isStopped()){
         RefreshRates();
         static datetime lastServerTime, lastServerTimeLocal;
         datetime serverTime = TimeCurrent();
         if(lastServerTime != serverTime){
             lastServerTime = serverTime; lastServerTimeLocal = TimeLocal(); }
         else
             serverTime = LastServerTime + TimeLocal() - lastServerTimeLocal;
         :
         Sleep(1000);
    }
    Not compiled or tested.
Drazen Penic
2403
Drazen Penic 2014.06.18 16:09  

Thanks.

I thought that this is the only way, but I hoped there is some function I missed :) 

/
To add comments, please log in or register