MetaTrader Demo Server Time Zone

 
Is the MetaTrader Demo Server's Time Zone +2 hours GMT?

Say for instance, if GMT is 18:00, is Meta Trader's demo server showing 20:00 ?

I keep having problems with the time. I'm using a GMT calendar of economic events and I can't figure out how many hours away GMT is from the MetaTrader demo server.
 
Vooch,

The time of the server is listed at the top of the Market Watch window. Time will differ depending on the broker that you use. Currently the MetaQuotes server runs, as you've summised, GMT + 2 hours.

Cheers
Martin
 
Thanks.
 
This topic of timezone has come up a few times. Unfortunately MT do not consider it important to change to code to a recognised timezone. Instead it is set as the local timezone where the server is, which of course is totaly meaningless unless the server happens to be in one of the commonly used timezones such as GMT or EST.

This gets worse....

Since a lot of indicators work on daily data, the market close according to MT is offset by as many hours as the server is away from GMT or EST. This means that the end-of-day bar on MT is not the same end-of-day bar on other applications that reference their server time as GMT.

This means that there are errors in the indicators. This can be corrected by writting an estensive amount of code to manually figure out when the market closed, but this has to be changed at each change of daylight saving.

There have been numerous requests to change the time code to either user definable or at least set the time on the server to GMT at a minimum, but these go unanswered as I am sure this request will to.

It is really an excellent package and I use it everyday, but I have stopped trying to write code in MT reliant on time, since it is wrong. Something to be aware of.

Des
 

As a workaround you can compute the server TZ offset in the OnInit() method of your EA/indicator:

int   gServerGmtOffset = 0;

int OnInit() {
  ...
  gServerGmtOffset = (int) (TimeTradeServer() - TimeGMT());
  ...
}

Then, in OnTick(), you can convert the server time to GMT time with the following formula:

datetime serverBarTimes[1]
CopyTime(_Symbol,_Period, 0, 1, serverBarTimes );
datetime gmtBarTime = serverBarTimes[0] - gServerGmtOffset;
 
pietrop: compute the server TZ offset in the OnInit()
Don't try to use any price or server related functions in OnInit (or on load,) as there may be no connection/chart yet:
  1. Terminal starts.
  2. Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
  3. OnInit is called.
  4. For indicators OnCalculate is called with any existing history.
  5. Human may have to enter password, connection to server begins.
  6. New history is received, OnCalculate called again.
  7. New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent and prices are valid.
 
whroeder1:
Don't try to use any price or server related functions in OnInit (or on load,)

You're right, it's better to do it in OnTick() (EAs) or OnCalculate() (indicators).

void OnTick() {
  ...
  gServerGmtOffset = (int) (TimeTradeServer() - TimeGMT());
  ...
}

This has also the advantage of handling the case where the server DST changes while the EA/indicator is already running.

 
You can also make a custom symbol with GMT/DST offset from main quotes if you want a 5-bar per week daily chart from a broker whose quotes differ from proper GMT+2 timezone.