Loading…

Connection Quality Ledger

Traders who have ever had a strategy misbehave and suspected "the connection was bad that day" usually have nothing to point to - the terminal does not keep a history of its own connection quality. This EA builds one, one CSV row per calendar day, for as long as it stays attached to a chart. Three things are recorded honestly, and the honesty matters more than usual here because it would be easy to overclaim. Reconnects are counted from IsConnected() transitioning from false to true, checked once a second by a timer rather than in OnTick - OnTick simply stops firing while disconnected, so a script that only checks the connection state inside OnTick can never see the moment it comes back, because there is no tick to trigger that check. A one-second timer runs regardless of connection state and catches the transition directly. Feed gaps are minutes where no tick arrived at all, counted from wall-clock time whether or not the terminal is currently connected, so a gap caused by a dropped connection and a gap caused by a genuinely quiet market both count. The third figure is deliberately NOT called "ping" in the code comments, because MQL4 has no network round-trip API of any kind - no ICMP, no TCP handshake timing, nothing that measures actual latency to the trade server. What this EA reports instead is the spacing between consecutive ticks in milliseconds, which is a proxy for how responsive the feed feels, not a measurement of network latency. The .txt and the column header both say so plainly rather than dressing it up as a ping value. Notes and limitations Only one running instance's data lands in the file - two charts each running this EA would double-count the same connection. Attach it to exactly one chart. The "tick interval" figure is a feed-responsiveness proxy, not a real network ping; do not present it as latency to anyone who might act on it as such. A day that starts partway through (EA attached mid-day) or ends partway through (removed mid-day) still writes a row for that day, flagged incomplete in the last CSV column - filter those out before comparing "full day" figures against each other. GetTickCount() wraps roughly every 49.7 days; a wrapped interval sample is discarded rather than recorded as a huge outlier, so this cannot silently poison the average.

Expert advisor · MT4 · v1.0 · Free

About Connection Quality Ledger

Connection Quality Ledger is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 3 settings, such as Ledger file name, Gap threshold secs and Timer seconds. MQL source code included.

Files in the download: ConnectionQualityLedger.ex4, ConnectionQualityLedger.mq4, ConnectionQualityLedger.txt.

Settings

SettingDefaultWhat it does
Ledger file nameConnectionQualityLedger.csvLedger file, written under MQL4\Files\
Gap threshold secs30Silence longer than this between ticks counts as one feed gap
Timer seconds1Poll interval for the reconnect watchdog

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

Expert advisors (EA) for MT4 & MT5 · PolyMaria