Some of my backtests are hampered by time conversion problems. I chose to draw an include file which manages converting to/from times in a variety of locales so I can easily assess the London time, New York time, etc.. I believe it accounts for daylight savings time accurately, even taking into account the old or new rules for DST in the united states, depending on year.
I am uploading the file since it's wonderful to talk about and I am hoping for a bit of help from fellow developers with the QA.
I'd advise against calling ConvertDateTime(...) with every timestamp that requires converting since it could be processor intensive. I call it around the very first bar of every Sunday to find the time offset and then reuse the offset for the remainder of the week.
Here is an illustration:
Inserted Code // when that is the first bar or a new week compute mid time offset if (I == Bars - 1 || (TimeDayOfWeek(Time#91;I#93;-RRB- lt; TimeDayOfWeek(Time#91;I 1#93;-RRB-)) iEasternOffset = ConvertDateTime(Period #91;I#93;,TIME_SERVER,TIME_NEWYORK) - Time#91;I#93;; and then it is possible to use the offset with impunity...
Inserted Code datetime dtEasternTime = Time#91;I#93; iEasternOffset;
As is, the constant settings operate for NorthFinance. You will probably have to bring the offset to your broker in the constants and in the GmtOffset(...) function.
I can not upload an mqh, so I've attached it as txt.
https://www.cliqforex.com/attachment...1970386558.txt