Ce code devrait avoir pas mal de succès chez les codeurs, il met à disposition la fonction TimeGMT() qui retourne l'heure GMT en se basant sur l'heure du broker, l'heure du PC et sa configuration de timezone (pour peu qu'elle soit correcte).
Code
#import "kernel32.dll"
int GetTimeZoneInformation(int& a[]);
#import
int broker2gmt; // time offset from broker time to gmt in seconds
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init() {
//----
int tzdata[172];
int tzinfo = GetTimeZoneInformation(tzdata);
broker2gmt = (3600.0 * MathRound((TimeLocal() - TimeCurrent()) / 3600)) + (60 * tzdata[0] - 3600 * (1 - tzinfo % 2));
}
//+------------------------------------------------------------------+
//| return GMT time according to local computer timezone settings |
//+------------------------------------------------------------------+
datetime TimeGMT() {
return(TimeCurrent() + broker2gmt);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start() {
//----
Comment("GMT=", TimeToStr(TimeCurrent() + broker2gmt));
//----
return(0);
}