Copier Drift Healer
Most copiers only act at the moment a new signal arrives. Between signals, small differences accumulate - a slippage-adjusted fill, a manually nudged position, a missed poll during a reconnect - and nothing ever corrects them until the next fresh trade happens to paper over the gap by coincidence. This EA runs continuously and treats "does this account's net exposure per symbol match the master's" as an ongoing target, not a one-off action. Net exposure means buy lots minus sell lots on a symbol, not gross per-direction volume. A drift healer's job is deciding whether this account carries the same market risk as the master; two opposite- direction master orders that net to zero exposure are not something a healer needs to reproduce order for order, since their combined effect on account risk is nothing. Every reconciliation pass computes the drift (target net exposure minus this account's own net exposure) per symbol. A drift smaller than InpDriftToleranceLots is left alone entirely - closing a 0.001 lot gap that only exists because of broker-side rounding would generate more noise than it fixes. A drift larger than InpMaxHealLotsPerPass is capped to that amount for the pass, so a large divergence (for example after a terminal was offline for a while) is healed gradually across several passes rather than in one large market order that could itself move the price against the account. Healing always prefers closing an existing opposite-direction order over opening a new same-direction one, since closing is the smaller, cheaper action whenever it is available. Notes and limitations - This EA does not write the master snapshot file itself - it only reads one. Producing that file on the master side is outside this project's scope. - Works on NET exposure per symbol, not gross per-direction volume. A copier that must preserve two separate opposite-direction positions as distinct trades needs a different tool (see PartialFillAwareCopier in this catalogue, a separate project, for gross-volume reconciliation). - Healing this EA's own magic-tagged orders only. It never closes a manually opened or foreign-magic position, even if that position contributes to the symbol's overall account exposure in the trader's own head. - A stale master snapshot pauses healing entirely rather than assuming the master went flat; if the master terminal is down for longer than InpMaxSignalAgeSec, this account's exposure is left exactly where it was until fresh data returns. - The per-pass cap means a very large drift takes multiple passes (InpPollIntervalSec apart) to fully close, by design - this is a deliberate throttle, not a bug.
Expert advisor · MT4 · v1.0 · Free
About Copier Drift Healer
Copier Drift Healer is an expert advisor (trading robot) for MetaTrader 4. It has 8 settings, such as Master book file name, Copy ratio and Magic number. MQL source code included.
Files in the download: CopierDriftHealer.ex4, CopierDriftHealer.mq4, CopierDriftHealer.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 |
|---|---|---|
| Master book file name | drift_healer_master_book.csv | File in MQL4\Files\ - master's open-order snapshot |
| Copy ratio | 1.0 | Multiplier applied to master's net exposure per symbol |
| Magic number | 46400 | Magic number stamped on healing orders this EA opens |
| Slippage points | 30 | Maximum acceptable slippage, in points |
| Max signal age sec | 90 | Ignore a master snapshot older than this many seconds |
| Drift tolerance lots | 0.02 | Drift smaller than this (in lots) is left alone - avoids rounding churn |
| Max heal lots per pass | 1.0 | Cap on lots healed for a single symbol in one reconciliation pass |
| Poll interval sec | 5 | Seconds between reconciliation passes |
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 · MT4 Expert Advisor · MQL4 Source Code