Loading…

GMT Offset Auto Detector

Every broker publishes a nominal GMT offset for its server clock, and every serious session-based strategy needs to know it accurately - but the published figure is not always current, and some brokers do not publish it at all. FX markets close for the weekend at a fixed point in GMT terms: 22:00 GMT on Friday during the northern-hemisphere winter, 21:00 GMT during summer. The server's own timestamp on the last bar before that gap, and the first bar after it, is a direct, unarguable measurement of the offset - no published table required. This script walks the loaded H1 history looking for the weekly gap (a jump of roughly 48 or more hours between two consecutive stored bars), reads the broker-local hour on the bar closing into that gap, and compares it against the fixed GMT anchor for that time of year. It repeats this for several recent weeks and reports both the individual readings and their average, so a single anomalous week does not skew the answer. If the readings vary across the scanned weeks rather than staying flat, that is itself useful information: it means the broker's clock shifts with daylight saving, and BrokerDstTransitionTable should be run next to map the exact transition dates. Notes and limitations - The anchor assumes the standard FX weekly close (22:00 GMT winter, 21:00 GMT summer, EU daylight-saving rule as the approximation for which side of the year a given week falls on). A broker with a genuinely unusual weekly close time will need manual verification against this baseline. - 24/7 instruments (most crypto CFDs) have no weekend gap at all and this script will correctly report that none was found - it is not built for those symbols. - This measures the offset AT THE TIME of each historical gap, not necessarily the broker's offset right now if the broker has since changed its policy - the most recent scanned week is the most current reading. - A thin or newly listed symbol with gaps in its own price history for reasons unrelated to the weekly close can produce a false gap reading; cross-check with a well-established major if the result looks odd.

Script · MT5 · v1.0 · Free

About GMT Offset Auto Detector

GMT Offset Auto Detector is a script for MetaTrader 5. It has 2 settings, such as Symbol and Weeks to scan. MQL source code included.

Files in the download: GmtOffsetAutoDetector.ex5, GmtOffsetAutoDetector.mq5, GmtOffsetAutoDetector.txt.

Settings

SettingDefaultWhat it does
SymbolSymbol to analyse, empty = current chart symbol
Weeks to scan6How many recent weekly gaps to inspect

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Trading Sessions · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria