MetaTrader Tips – Time Zone Correction

May 11th, 2010 | Filed under MetaTrader 4 Tips

MetaTrader TimeAt times traders may need to perform a time synchronization task when expert advisor is working. Prohibition or permission for orders opening in certain time spans during 24 hours, cancellation of suspended orders after certain time, prohibition against work of the expert advisor on holidays, trade permission only at news-time etc. may be required.

Time in MetaTrader 4 client is read from the server and depends on the brokers configuration. Normally, time on the brokers server is set to their local time. MetaTrader 4 has on means for determination or automatic adjustment of the time zone. There is a possibility at our disposal to know the server time and local time of the computer on which the MetaTrader 4 client is working. Accordingly, if we use such dimensions as hours, minutes or even specific dates then we have to provide correspondence between local time and time on the server. This task is owned by the trader, while the programmer considering the above limitations can provide only the means for configuration.

With respect to zero meridian, time can have a shift of -12 to +12 hours. I.e. within 24 hours. however, two dates fall within this span. These are the current date (from 0 to +12) and previous date (from -12 to 0).

Let’s take a look at an example.

Expert advisor has to work only during the session at NYSE. NYSE is opened at 9:30 AM and closed at 4:00 PM as per Eastern Time. If the time will be converted to Greenwich Mean Time, then we will have GMT-5. We have to configure the expert advisor to work during this time. If we are located at the GMT-0 zone, then for correct synchronization we have to know our location with respect to zero meridian as well. E.g., our time zone is GMT+1. Thus, time difference makes up 6 hours. As the reference point is time on the side of the Metatrader 4 terminal, then the relative time shift will be -6 hours.

Let’s move on to specific figures and computations. Local time on trader’s computer is 2:00 PM. We find the time in New York by shifting the current time 6 hours back. We get 8:00 AM. It is too early for the expert advisor to operate; the stock exchange is not opened yet. The exchange will open when the local time will be equal to 3:30 PM.

Let’s summarize. If the expert advisor has the TimeShift configuration, then the task of the trader is to know the difference between the local time and the time of event for which the expert advisor has to be configured. If local time precedes the required event, then the shift will have the “+” sign, and if local time follows the event, then the shift will have the “-“ sign.

by Alexey Koshevoy, AirBionicFX founder and CEO

Related posts:

  1. MetaTrader Tips – Expert Advisor Optimization
  2. MetaTrader 4 Tips
  3. MetaTrader Tips – Expert Advisor Back Testing
  4. MetaTrader Tips – Save Bandwidth Disable News
  5. MetaTrader Tips – Expert Advisor Installation

Comments are closed.