Loading…

Bar Open Tick Reliability Study

A new bar's Time[0] is stamped with the rounded-to-the-period boundary, but the terminal only actually learns a bar has started once the next tick after that boundary arrives. In a fast market that gap is close to nothing; on a quiet cross overnight it can be many seconds. Anything that reacts to "new bar" as if it were an instant event - an entry filter, a session-open script, a news-time trigger - is really reacting some unknown delay later, and this script measures what that delay actually is on the symbol and timeframe being watched. History cannot answer this question: MQL4 never stores a per-tick arrival timestamp for a closed bar, only its rounded open time. The only honest way to measure the gap is to sit and watch it happen, so this runs as a live monitoring loop rather than a walk over history - it polls for a change in Time[0] and, the instant it sees one, reads TimeCurrent() to see how many seconds into the new period the market actually already was. The result is a distribution, not a single number: a mean, median, standard deviation, min/max, and a bucketed histogram (0s, 1s, 2s, 3s, 4s, 5-9s, 10-29s, 30-59s, 60s+) built from however many new bars were observed during the run. Notes and limitations Delay is reported in whole seconds only. MQL4's TimeCurrent() has no sub-second resolution, so this cannot measure millisecond-level tick latency - it answers "how many whole seconds late", not "how many milliseconds late". This is a LIVE script, not a historical one - it must be left running on a chart to collect samples, and results depend on market conditions during that specific run (session, news, liquidity). Run it across different times of day for a representative picture rather than trusting a single short session. A clock-skew guard clamps any negative computed delay to zero (broker server time and the reported delay can disagree by up to a second in rare cases); this does not affect the distribution meaningfully.

Script · MT5 · v1.0 · Free

About Bar Open Tick Reliability Study

Bar Open Tick Reliability Study is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 4 settings, such as Timeframe, Bars to monitor and Poll ms. MQL source code included.

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

Settings

SettingDefaultWhat it does
TimeframePERIOD_M1Timeframe whose bar-open delay is measured
Bars to monitor60Number of new bars to observe before reporting
Poll ms150Sleep between polls while waiting for a new bar (ms)
Save csvtrueWrite every sample's delay to a CSV file

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 · News Trading · Alerts · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria