Discussing the article: "Broker Time vs Real Market Time — Building a DST-Aware Session Clock in MQL5"

Check out the new article: Broker Time vs Real Market Time — Building a DST-Aware Session Clock in MQL5.

Session filters can run an hour off when a broker and a market change their clocks on different dates. This article presents an MQL5 include file, SessionClock.mqh, that converts London, New York, and Tokyo sessions to broker hours for a stated daylight saving time (DST) schedule (EU, US, or fixed) and winter offset. A second script estimates the schedule from server history. It uses calendar arithmetic, so it also works in the Strategy Tester.

Many session-filtered Expert Advisors have a hidden vulnerability. It raises no error in the Experts log, and in a backtest it is easy to miss. The EA compiles, deploys, and behaves as expected for months. Then, after a clock change, the session filter that should wait for the London open fires an hour early, or trades that should close before the New York close stay open an extra hour. The cause is rarely the trading logic. It is the relationship between broker server time and real market time, which shifts twice a year with daylight saving time (DST).

Most brokers move their server clock for DST, so the value of TimeCurrent() shifts by one hour. A session hour hardcoded in broker time stays correct only while the market it represents moves its clock together with the broker. The US and the EU do not switch on the same dates. The US moves to DST on the second Sunday of March and back on the first Sunday of November. The EU moves on the last Sunday of March and the last Sunday of October. This creates two mismatch windows: two to three weeks in spring, and exactly one week from the last Sunday of October to the first Sunday of November. In these windows London and New York are 4 hours apart instead of 5, and a filter that is right for most of the year can be one hour off.

This article presents a practical solution from the ground up. It explains why TimeCurrent() alone is not enough for session filtering and walks through the arithmetic of converting broker time to market session time. By the end, you will have a reusable MQL5 include file with the function GetMarketSessionHour(), which computes the session hour at runtime for London, New York, and Tokyo, so you no longer adjust session hours by hand after each clock change. You state the DST schedule and the winter offset of your broker once. The file supports the EU schedule, the US schedule, and a fixed offset.


Author: Ushana Kevin Iorkumbul