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 · MT4 · v1.0 · Free
About Bar Open Tick Reliability Study
Bar Open Tick Reliability Study is a script for MetaTrader 4. 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.mq4, BarOpenTickReliability.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Timeframe | PERIOD_M1 | Timeframe whose bar-open delay is measured |
| Bars to monitor | 60 | Number of new bars to observe before reporting |
| Poll ms | 150 | Sleep between polls while waiting for a new bar (ms) |
| Save csv | true | Write every sample's delay to a CSV file |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Trading Sessions · News Trading · Alerts · MT4 Script · MQL4 Source Code