Loading…

Local Trade Copier Master

This is one half of a local trade copier. On its own it does nothing but publish: it watches this account's open market orders and writes their ticket, symbol, direction, volume, entry price, stop loss, take profit and magic number to a shared CSV file every time something changes. Local Trade Copier Slave, running as a separate EA - typically on a different terminal installation, watching a different account - reads that file and mirrors the same direction. Reverse Copier reads the same file and does the opposite: it opens the reverse side, as a hedge. Both are separate CodeBase submissions; search for them by title to find the companion this EA is meant to pair with. The file lives in Common\Files, not the per-terminal MQL4\Files sandbox used by nearly everything else in this catalogue. That is a deliberate, non-obvious choice worth understanding before you rely on it. Every MetaTrader terminal installed on a machine has its own MQL4\Files sandbox, and one terminal cannot see another terminal's sandbox at all - by design, for isolation. Common\Files is the one folder every terminal installed on that machine can read and write, which is exactly what a local copier needs: master and slave are two separate terminal processes, on the same PC, each logged into a different account, and they need one place to hand data between them. This only works when both terminals run on the same physical machine (or the same Windows user profile on a VPS) - it is not a mechanism for copying trades to a different computer or a different broker's server over a network. A calendar file like the one News Time Auto Flat reads, by contrast, has no reason to leave its own terminal's sandbox, which is why that project uses MQL4\Files instead. The file is rewritten whenever an order opens, closes, is partially closed, or has its stop loss or take profit modified - not on a fixed interval - so a slave sees a change within one timer tick of it happening, plus a heartbeat rewrite (InpHeartbeatSec) even with no change, so a slave with a staleness check never mistakes "nothing happened" for "the master has stopped writing." A closed order stays in the file with IsClosed=1 for InpClosedRetentionSec after it closes, rather than vanishing the instant it leaves the trade pool, so a slave polling on its own schedule cannot land between two master writes and miss the close event entirely. Notes and limitations - Same PC only. Common\Files is shared between terminals installed on one machine; it is not a network protocol and does not copy trades to a different computer, VPS, or broker's own copy service. - This EA only publishes. It never opens, closes, or modifies a trade on this account - watch the companion Local Trade Copier Slave or Reverse Copier for the EA that actually acts on the mirrored side. - If two different EAs both write to the same channel name, the second write simply overwrites the first each cycle - there is no locking or merge, so give each master account its own channel name. - On removal or terminal shutdown, the file is left exactly as it last was written. It does not clean itself up; a slave relies on its own staleness check (InpMaxFileAgeSec on the slave side) to notice the master has stopped. - Any trade this master account places is mirrored, or hedged, on whichever companion account is watching this channel. If this account is used for discretionary trading you do not want copied, either stop this EA or filter it to a specific magic number with InpMagicFilter.

Expert advisor · MT4 · v1.0 · Free

About Local Trade Copier Master

Local Trade Copier Master is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 4 settings, such as Channel name, Magic filter and Heartbeat sec. MQL source code included.

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

Settings

SettingDefaultWhat it does
Channel namedefaultChannel name (must match the slave's input)
Magic filter-1Magic number to track (-1 tracks every magic)
Heartbeat sec5Max seconds between writes even with no change
Closed retention sec120How long a closed order stays flagged before it is dropped

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

Expert advisors (EA) for MT4 & MT5 · PolyMaria