Determine offset between GMT and broker time

 

I have seen quite a few articles on determining the difference between GMT and local time, but I need to include into my EA the difference between GMT and broker time. I need my EA to course correct itself when encountering DST changes, different brokers, etc. Can someone help me in determing what the best way is to identify the difference between broker time and GMT automatically? Also needs to be able to work for backtesting.

Thanks!

 


I am using mt4. There is no TimeGMT() as shown in your code. Do you have a separate routine that contains the GMT determination?

Thanks

 
jeff_calgary:


I am using mt4. There is no TimeGMT() as shown in your code. Do you have a separate routine that contains the GMT determination?

Thanks


Actually, I found your call to TimeGMT() in your code library. I will work through this. Just trying to see where you compare the GMT time and the broker time.

 


I am looking for some real basic stuff. All I want to do is to allow my EA to only open trades between x hour and x hour GMT. That is all I need the GMT time for. But of course, this has to work on all brokers without the user having to input the GMT offset.

Thanks

 
#import "kernel32.dll"
  int GetSystemTime(int& buf[]);
#import
//+------------------------------------------------------------------+
//|                                 Function  :      void SetObject()|
//|                                 Copyright © 2010, XrustSolution. |
//|                                           mail: xrustx@gmail.com |
//+------------------------------------------------------------------+
int GetTimeZone(){
        int in_ho = TimeHour(TimeCurrent());
        int st[4];
        GetSystemTime(st);
        int GMT = st[2] & 0xFFFF;
        int res = in_ho - GMT;
        if(res<0){in_ho+=24;}
        return(in_ho-GMT);  
}
Reason: