Loading…

Inter Tick Time Snapshot

An average tick interval hides the shape of a feed. A symbol producing one tick every second on average could be doing that steadily, or it could be sitting idle for four seconds and then firing five ticks in the same instant during a burst - two very different feeds for anything that reacts to tick timing, and an average alone cannot tell them apart. MQL4 gives a Script no tick event at all - only Experts get OnTick(). This works the way the rest of this catalogue's tick-density tools do: poll MarketInfo(symbol, MODE_TIME) on a short timer and treat a changed value as one new tick, timing the gap with GetTickCount() at the moment the poll notices the change. This is not the broker's own microsecond tick timestamp - MQL4 does not expose one to a Script - so every reported gap carries up to one poll interval of measurement slack, and two ticks landing inside the same poll interval get merged into one. A short InpPollIntervalMs narrows that slack at the cost of more CPU spent polling. The result is reported as a full distribution: minimum and maximum gap, mean, median, and a histogram bucketed from sub-100ms up to half a minute and beyond. The median in particular is often far more informative than the mean on a bursty feed, since a handful of multi-second idle gaps can drag the mean upward while the typical gap between ticks in an active burst stays small. Notes and limitations - This measures ARRIVAL as seen by a polling loop, not the broker's own tick timestamp - see the full description for why MQL4 has nothing finer to offer a Script. Treat the numbers as accurate to within roughly one poll interval, not to the millisecond. - Two or more ticks landing inside the same poll interval are counted as one - the reported tick count is a lower bound on how many ticks the broker actually sent during a genuinely fast burst. - The very first detected tick is used only to start the clock and is dropped from the reported statistics, since it has no real predecessor to measure a gap against. - Sampling blocks the script for the full InpSampleSeconds (or until IsStopped() is triggered by removing the script) - this is expected; a Script has no way to run in the background between polls. - Results are specific to the exact time window sampled. A symbol's tick rate varies enormously between session opens, news releases and quiet hours - run at a time representative of what you actually want to know about.

Script · MT4 · v1.0 · Free

About Inter Tick Time Snapshot

Inter Tick Time Snapshot is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 5 settings, such as Symbol, Sample seconds and Poll interval ms. MQL source code included.

Files in the download: InterTickTimeSnapshot.mq4, InterTickTimeSnapshot.txt.

Settings

SettingDefaultWhat it does
SymbolSymbol to sample (blank = this chart's symbol)
Sample seconds120How long to sample
Poll interval ms15Poll frequency - lower catches more ticks but costs more CPU
Max ticks5000Sampling stops early if this many ticks are captured first
Save csvfalseAlso write every individual gap to a CSV file

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 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: Alerts · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria