Loading…

Multi Symbol Bar Clock

A portfolio EA or cross-symbol indicator that needs to act "once per bar, across several symbols" usually takes a shortcut: it treats a new bar on the CHART's own symbol as a proxy for "new bar everywhere", and simply reads iTime() on the other watched symbols at that moment. That shortcut is wrong whenever the other symbols have not actually rolled their own bar yet - a slower-updating symbol, a symbol whose feed briefly lagged, or simply a chart timeframe boundary the other symbols do not share all produce a tick where the chart symbol is on a new bar and a watched symbol is still reading its previous one. Anything gated on "new bar" at that moment silently acts on stale data for that symbol. This library tracks each watched symbol's last-confirmed bar time independently and only reports a completed synchronisation round once EVERY symbol has individually advanced past its own previous round's bar time - not the first symbol to advance, all of them. A symbol that has already advanced this round is remembered as such, so a later poll only needs to check the symbols still pending, and the round fires exactly once, on the exact call where the last pending symbol catches up. Notes and limitations - A symbol whose history is not ready yet (iTime() returns 0) is treated as "still pending", not as an error on every poll - it simply never advances until its feed genuinely produces bar data. - A symbol that never advances (delisted, wrong name, broker does not offer it) means the round never completes and Poll() never returns true again - the demo's "stuck symbol" test shows this deliberately. Check MissingCount() after Init() to catch a misspelled symbol early. - The clock only knows about bar TIMES, not bar content - it cannot detect a symbol whose feed is technically ticking but stuck repeating the same closed bar's data (a broker-side data fault), only a symbol whose bar time genuinely never changes. - PollWithTimes() bypasses this library's own iTime() reads entirely, so it is only as correct as the times[] array the caller supplies - it does not re-validate them against the broker.

Script · MT5 · v1.0 · Free

About Multi Symbol Bar Clock

Multi Symbol Bar Clock is a script for MetaTrader 5. MQL source code included.

Files in the download: MultiSymbolBarClock.mq5.mqh, MultiSymbolBarClock.txt, MultiSymbolBarClockDemo.ex5, MultiSymbolBarClockDemo.mq5.

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: Multi-Currency · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria