Loading…

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 · MT5 · v1.0 · Free

About Latency Monitor

Latency Monitor 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 Spike threshold ms, Alert threshold ms and Alert cooldown sec. MQL source code included.

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

Settings

SettingDefaultWhat it does
Spike threshold ms2000Tick gap that counts as a spike and gets logged, ms
Alert threshold ms5000Tick gap that triggers an Alert, ms (must be >= spike threshold)
Alert cooldown sec60Minimum seconds between two Alert popups
Csv file nameLatencyMonitor_Spikes.csvSpike log, in MQL5\Files

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: Alerts · Arbitrage · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria