Loading…

Equity Proportional Basket Copier

A trade-by-trade copier reproduces every one of the master's individual orders, at a lot size usually derived from a single fixed multiplier that has no real relationship to what the slave account can actually carry. This EA instead treats the master's basket as a STATE, not a stream of events: on the master's chart it periodically aggregates every own-magic open position into net lots per symbol and publishes that snapshot along with the account's own equity; on the slave's chart it reads that snapshot, computes the ratio of its own equity to the master's (capped by InpMaxEquityRatio so an unusual equity mismatch cannot demand an absurdly oversized position), and reconciles its OWN net position on each symbol toward the scaled target - opening more, partially closing, fully closing, or flattening a symbol the master has gone flat on, none of which corresponds to copying any single master order. Because reconciliation works from the master's current state rather than its trade history, a slave that was offline when the master opened a position still ends up with the correct proportional exposure the next time it reconnects and polls - a trade-by-trade copier has no way to "catch up" like that once an individual copy event is missed. A stale master snapshot (older than InpStaleSnapshotSec) is treated as "reconciliation paused", never as "the master went flat" - this project does not flatten on silence; pair it with the Master Silence Failsafe or Slave Kill Chain Guard projects elsewhere in this catalogue for that. Notes and limitations - Tracks at most 30 distinct symbols in one basket snapshot (a documented fixed-array cap, MAX_SYMBOLS in the source) - a master basket wider than that will log a warning for the overflow symbols and simply not publish them. - Reconciliation is net-lots-per-symbol, not per-ticket - it cannot reproduce a master that deliberately holds several separately-managed positions on the same symbol at different stop levels; only the net exposure is matched. - A direction flip (master goes from net long to net short on a symbol) is handled as flatten-this-poll, reopen-next-poll, to avoid sending an opposing order in the same pass as a still-processing close - there is a brief window with no position on that symbol during a flip. - Does not itself detect a stale or missing snapshot as a reason to flatten existing slave positions; it simply stops adjusting them. See the notes above for the projects that do handle master silence. - Reimplements its own NormalizeLots helper inline rather than including another project's file, per this catalogue's no-cross-project-include rule.

Expert advisor · MT5 · v1.0 · Free

About Equity Proportional Basket Copier

Equity Proportional Basket Copier is an expert advisor (trading robot) for MetaTrader 5. It has 8 settings, such as Role, Instance tag and Master instance tag. MQL source code included.

Files in the download: EquityProportionalCopier.ex5, EquityProportionalCopier.mq5, EquityProportionalCopier.txt.

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

Settings

SettingDefaultWhat it does
RoleROLE_SLAVEWhich side of the copy relationship this chart plays
Instance tagShared filename tag for THIS master; blank = auto from account number (MASTER role only)
Master instance tagThe MASTER's tag to read from (SLAVE role only)
Magic filter47100Magic number this side's own basket positions carry (own orders only - never touches foreign-magic t
Snapshot interval sec15How often the master rewrites its snapshot / the slave reconciles
Max equity ratio5.0Safety cap on the slave/master equity ratio, however large the real ratio is
Stale snapshot sec120A master snapshot older than this is ignored (no reconciliation that poll) rather than acted on
Slippage points30Maximum acceptable slippage, in points, for basket adjustment orders

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 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: Risk & Lot Size · Trade Copier · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria