Testing MT5 session boxes around daylight-saving changes
A session box can look right on the current chart and still be an hour out when you scroll back across a daylight-saving change. I would test the time conversion separately from the high/low calculation.
1. Define the session in the time zone the trading rule uses. Treat the interval as start inclusive and end exclusive so the bar on the boundary is counted once.
2. Convert each historical session to broker-server time using the offset for that date. Check a week when the US and Europe change clocks on different dates, and test a session that crosses midnight.
3. Calculate the range from M1 bars inside the converted interval. Compare the result against the same M1 data on an M15 and an H1 chart. Log the broker timestamp of the first and last included bars, especially if the history has gaps.
4. Check the current session separately. Its high and low can still change while it is open. Once it closes, switching chart timeframe should leave the completed range the same if the M1 history is unchanged.
How do other MT5 developers handle historical broker time: an explicit offset schedule, a user-supplied rule, or another approach?
- Session-range EAs and the 25 Oct to 1 Nov DST gap on GMT+2/+3 servers
- MT5 Time Synchronization: Can We Align Broker Server Time with Local PC Time?
- TimeDaySavingLight () Function
I'd use an explicit offset schedule, not TimeGMT() in the tester. TimeGMT() just equals server time there, so a live auto-offset can be an hour out on history, especially when the US and EU clocks change on different dates. I run the same session test, then shift the server time by one hour and run it again. If the entries move, the logic is tied to the broker clock. I'd rather type the broker's DST rule as an input than guess it from the weekend open.