Loading…

Clock Skew Warning Banner

The gap between TimeCurrent() (server/quote time) and TimeLocal() (the trading machine's own clock) is not zero by design - a broker running on a different UTC offset always has a nonzero gap, and that alone means nothing is wrong. What actually indicates a problem is that gap CHANGING after the fact: the local PC clock being manually adjusted or drifting, a daylight-saving edge handled inconsistently between the terminal and the OS, or the price feed stalling while the local clock keeps advancing regardless. This banner snapshots the server-minus-local offset once at attach time and warns only when the LIVE offset later moves away from that snapshot by more than a threshold - not on the raw offset itself. A VPS whose clock silently jumped, or a terminal that lost its feed while the desk clock kept ticking, both show up as the offset moving; a broker simply being in a different timezone does not. Notes and limitations TimeCurrent() only advances on a new quote for the chart's symbol. Over a weekend, after hours, or on an illiquid symbol it legitimately freezes while TimeLocal() keeps advancing - this alone widens the measured offset and can trigger a false positive that has nothing to do with an actual clock problem. InpIgnoreWhenMarketClosed softens this by suppressing the banner once the last quote looks stale, but cannot eliminate the false positive completely on a thinly-traded symbol that ticks just often enough to look "alive" while still drifting slowly out of sync with real time. For the most reliable reading, attach this to a highly liquid, near-continuously ticking symbol (a major FX pair) rather than an illiquid one. This tool cannot fix a clock problem or resynchronise anything - it only reports that the gap moved. Sorting out WHY (local clock, DST handling, feed outage) is a manual step outside what an MQL4 indicator can do.

Indicator · MT5 · v1.0 · Free

About Clock Skew Warning Banner

Clock Skew Warning Banner is an indicator for MetaTrader 5. It has 6 settings, such as Drift threshold seconds, Check interval seconds and Ignore when market closed. MQL source code included.

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

Settings

SettingDefaultWhat it does
Drift threshold seconds90Warn once the server-vs-local offset moves by more than this many seconds
Check interval seconds5How often the offset is re-sampled
Ignore when market closedtrueSuppress the banner when the current symbol shows no recent tick (see limitation note)
Stale quote seconds120A last-tick age above this is treated as "market closed" for the suppression above
Banner colorclrCrimsonBanner background colour
Banner text colorclrWhiteBanner text colour

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 → Indicators.
  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 indicator from the Navigator onto a chart and adjust the settings.

Download the PDF guide

Tags: MT5 Indicator · MQL5 Source Code

MetaTrader 4 & 5 indicators · PolyMaria