Handling Broker Time, Daylight Saving Changes, and Forex Session Close
Summary
This article describes updates to time-handling functions for trading software, focusing on daylight saving time, broker offsets, and the weekly forex session close. A change in the platform’s time-copying behavior meant future timestamps were no longer returned as before, which could distort broker-time offset calculations. The revised approach also covers historical daylight saving transitions, including Sydney’s changes back to the 1970s. A supplied transition table and test indicator are presented as ways to inspect the calculated local times and offsets.
The article also introduces a function that estimates the seconds remaining until the forex market closes without relying on the affected time-copying method. This can support rules that close positions or stop new entries before the weekend. Because there is no valid bar opening exactly at the stated New York Friday close, the calculation subtracts one second to identify the last valid bar time. The author cautions that brokers may stop quoting or accepting orders several minutes earlier, so calculated session times do not guarantee actual trading availability.
Key ideas
- Platform changes to timestamp retrieval can invalidate broker offset calculations that depend on future bar times.
- Daylight saving calculations need to account for region-specific transition rules and historical changes.
- A remaining-time-to-close function can support weekend position management and entry cutoffs.
- Subtracting one second helps locate the final valid bar when no bar opens at the session’s nominal close.
- Broker quotes and order acceptance may end before the calculated forex session close.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.