Loading…

Signal Pipeline Latency Auditor

When an EA's entries feel "late", the usual suspect blamed is broker or network latency. A surprising share of the actual delay is often the EA's own code: indicator reads, filter checks, and lot/stop calculation all take real time, and that time is invisible unless something is actually timing it. This program is a timing harness built around a plain fast/slow moving-average cross, chosen because it is deterministic and easy to verify by eye on a chart - the signal itself is not the point, the staged timing around it is. On every cross it records, in milliseconds via GetTickCount(): the time from the signal firing to the filter/prep stage completing, the time from there to the moment OrderSend would be called, and (when not in dry run) the actual OrderSend round trip itself. Every stage is logged to a CSV file under MQL4\Files\ (or MQL5\Files\ on the native MQL5 build) and echoed to the Experts log. Dry run is the default: every stage is timed except the real OrderSend round trip, and nothing is ever sent to the broker. Turning dry run off makes the program open a genuine minimum-size position purely to complete the round-trip measurement, then automatically closes it again a few seconds later - the exposure is momentary and diagnostic, not a trading strategy, and a session trade cap prevents it from opening measurement trades indefinitely if left running. Notes and limitations - With InpDryRun true (the default), the OrderSend round-trip column in the log is left as -1, since no order was actually sent. - The signal is a deliberately simple MA cross for demonstration purposes - this is a latency-measurement tool, not a trading strategy, and should not be judged or deployed as one. - Measurement timing uses GetTickCount(), which is millisecond resolution - adequate for comparing pipeline stages and network round trips, not for sub-millisecond profiling. - In live mode, each measurement trade carries real spread and commission cost even though it is closed within seconds - this is a genuine (small) cost of measuring a genuine round trip, not simulated. - The session trade cap resets only on EA restart, not on a timer - a long-running session hitting the cap will stop opening new measurement trades until reattached.

Expert advisor · MT4 · v1.0 · Free

About Signal Pipeline Latency Auditor

Signal Pipeline Latency Auditor is an expert advisor (trading robot) for MetaTrader 4 based on Moving Average. It looks for price differences (arbitrage). It has 10 settings, such as Dry run, Fast ma period and Slow ma period. MQL source code included.

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

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
Dry runtruetrue = time every stage except the real OrderSend round trip, never trades
Fast ma period5Fast moving average period for the demo cross signal
Slow ma period20Slow moving average period for the demo cross signal
Magic25400Magic number for measurement trades (live mode only)
Lot size0.01Minimum-size lot used purely to measure a real round trip
Stop loss pips20.0Conservative stop-loss distance for the measurement trade
Take profit pips20.0Conservative take-profit distance for the measurement trade
Auto close seconds5Seconds after opening before the measurement trade is auto-closed
Max trades per session20Hard cap on live-mode measurement trades per terminal session
Log file nameSignalPipelineLatency_log.csvFile under MQL4\Files\ - blank disables CSV logging

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 → Experts.
  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 expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Buy/Sell Arrows · Arbitrage · Moving Average · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria