Latency Compensating Copier
A plain signal copier that always sends a market order the instant it sees a new signal quietly assumes the copy happens at the same price the master got - it never does. Between the master's fill and this account's copy there is always some delay: file polling, network, terminal processing. By the time this EA acts, the market may already be materially away from the master's own price, and market-ordering into that gap chases a worse fill than the master actually got. This copier reads a signal file that carries the master's own fill price and timestamp, not just a bare direction, and classifies every signal into one of three outcomes. A small time lag and small price drift (within InpMaxDriftPipsMarket) is copied at market immediately - the gap is small enough that chasing it is fine. A larger drift (up to InpMaxDriftPipsLimit) is not chased at market at all; instead the EA places a pending limit order back at the master's own signal price, with an expiry equal to the signal's own staleness cutoff, so it only fills if the market comes back near where the master actually traded, and simply expires unfilled otherwise. A signal older than InpMaxLagSec, or one whose drift exceeds even the reprice tolerance, is skipped outright and logged as such - never traded at any price. Every decision - market copy, reprice, skip, or failure - is appended to a stats file with the exact lag in seconds and drift in pips, so lag and drift can be reviewed and the thresholds tuned to the actual distribution of delay this signal source produces. Notes and limitations - This EA reads only a single "latest signal" line per file, the same minimal feed shape used elsewhere in this catalogue - it is not a multi-signal queue, so a very fast burst of master trades can overtake this EA's polling interval and only the most recent one at each poll is seen. - A repriced pending order is a plain OP_BUYLIMIT/OP_SELLLIMIT with no attached stop-loss or take-profit; this EA's focus is entry price fidelity, not full trade management after the fill. - If the master's signal price is too close to the current market price to place as a pending order under the broker's stop/freeze level, the EA falls back to a market copy for that signal rather than rejecting it - documented behaviour, not a bug. - Lag is measured against the terminal's own clock versus the signal's embedded Unix timestamp; if the machine writing the signal file has a meaningfully wrong clock, lag figures will be wrong even though the copier's own logic is unaffected. - Does not manage or track fills on repriced pending orders after placement - whether it filled, expired, or was cancelled is visible in the terminal's own order history, not summarised by this EA.
Expert advisor · MT4 · v1.0 · Free
About Latency Compensating Copier
Latency Compensating Copier is an expert advisor (trading robot) for MetaTrader 4. It places pending buy/sell stop or limit orders and looks for price differences (arbitrage). It has 10 settings, such as Signal file, Symbol and Lots. MQL source code included.
Files in the download: LatencyCompensatingCopier.ex4, LatencyCompensatingCopier.mq4, LatencyCompensatingCopier.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Signal file | latency_signal.csv | Master signal file, in MQL4\Files\ |
| Symbol | EURUSD | Symbol this copier trades |
| Lots | 0.10 | Fixed lot size per copied trade |
| Max lag sec | 60 | A signal older than this is stale and is skipped, never traded |
| Max drift pips market | 3.0 | Price drift up to this many pips: copy immediately at market |
| Max drift pips limit | 12.0 | Price drift up to this many pips: reprice as a limit order at the master's price instead of chasing |
| Magic number | 48200 | Magic number stamped on orders this EA opens |
| Slippage points | 20 | Slippage allowed on market copies |
| Stats file | latency_stats.csv | Append-only per-signal lag/drift log |
| Poll interval sec | 2 | Seconds between checks of the signal file |
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 → Experts.
- 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 expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: Buy/Sell Arrows · Trade Copier · Arbitrage · Pending Orders · MT4 Expert Advisor · MQL4 Source Code