Discussing the article: "Implementing a DST-aware Trading Day Resolver in MQL5"

Check out the new article: Implementing a DST-aware Trading Day Resolver in MQL5.

With CTradingDay, an EA can reset its daily loss limit at the time its rule names, such as the New York close, not at the end of the broker's feed. CServerClockFit finds the server time zone and its DST rule from hourly bars. On the tested server, the New York close falls one hour before server midnight between the US and EU clock changes. Unit tests and tester runs check these clock times for that server only.

A daily loss limit has two parts. One is the amount. The other is the moment at which the counting starts again. The amount is easy to put into an input. The moment is harder, because the rules that name it do so in a time zone. The Trading Objectives page of FTMO, for example, says that the daily loss limit is recalculated at 00:00 CET (CEST in summer) from the balance recorded at that time. Other firms define different reset times. I did not verify those times. What matters is that the reset is defined in a specific time zone. That zone may differ from the zone of the broker's server.

An EA normally takes the day from the server clock. Such an EA reads TimeCurrent(), sets the hours, minutes, and seconds to zero, and calls the result today. Article 23732 does this in a daily loss circuit breaker. The article gives a reason: the server stamps every deal, so the server midnight stays consistent with the broker's own records. This rationale is sound for a limit that resets at server midnight. However, it does not cover a limit that resets at 17:00 in New York or at midnight in Prague. Prague uses CET and CEST, the zone of the FTMO reset.

On the server I tested, the three obvious choices give three different day starts. Server midnight is 00:00 on the server clock. Midnight in Central Europe is 01:00 on the same clock all year. The New York close at 17:00 is 00:00 on most days and 23:00 in a few weeks of each year. The United States and Europe change their clocks on different Sundays. A daily figure computed with the wrong one of these moves deals from one day to the next.

In this article, the New York close always means the clock time 17:00 in New York. The moment at which the broker's feed stops before the weekend is a different thing, and I call it the end of the feed. The section on fitting the server clock shows a week in which the two differ by one hour.

Author: Ali Akbar