Latency Monitor
"Latency" for a trade server usually means round-trip time, and MQL4 has no free way to measure that directly - the only round trip available to a script is a real trade, and repeatedly sending one just to measure timing costs spread and commission on every sample. This EA measures something related but free: how long the terminal goes between price updates it actually receives on the chart's symbol. A feed that has gone slow, or a connection that is about to drop, usually shows up here first as widening gaps between ticks, before the trader notices anything else is wrong. Every tick updates a running average, minimum and maximum gap. A gap past InpSpikeThresholdMs is logged to CSV; a gap past the higher InpAlertThresholdMs also triggers a popup Alert, throttled by InpAlertCooldownSec so a sustained slow patch produces one alert rather than one per tick. Notes and limitations - This measures quote-arrival latency (time between ticks this terminal receives), not broker round-trip execution latency. The two are correlated in practice but are not the same measurement - read the title as "how current is my feed", not "how fast would my order fill". - Only spikes (gaps at or above InpSpikeThresholdMs) are written to CSV, not every tick - use TickRecorder from this catalogue if a complete tick log is what you need. - Statistics accumulate for the lifetime of the chart attachment and reset on reattach; there is no rolling window or persistence across restarts. - This EA never trades. It only observes tick timing and reports on it.
Expert advisor · MT4 · v1.0 · Free
About Latency Monitor
Latency Monitor 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 Spike threshold ms, Alert threshold ms and Alert cooldown sec. MQL source code included.
Files in the download: LatencyMonitor.ex4, LatencyMonitor.mq4, LatencyMonitor.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Spike threshold ms | 2000 | Tick gap that counts as a spike and gets logged, ms |
| Alert threshold ms | 5000 | Tick gap that triggers an Alert, ms (must be >= spike threshold) |
| Alert cooldown sec | 60 | Minimum seconds between two Alert popups |
| Csv file name | LatencyMonitor_Spikes.csv | Spike log, in MQL4\Files |
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: Alerts · Arbitrage · MT4 Expert Advisor · MQL4 Source Code