Download MetaTrader 5

Can I get trading server time over the weekend?

To add comments, please log in or register
Drazen Penic
2686
Drazen Penic  

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  
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
15598
whroeder1  
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
2686
Drazen Penic  

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