Account Migration Executor
Moving an open book from one account to another by hand - closing each position on the old account, then re-opening its equivalent on the new one - is exactly the kind of one-time, high-stakes task where a slip (closing the wrong ticket, mistyping a lot size, forgetting a position) is expensive and easy to make under time pressure. This EA runs on both terminals involved. On the SOURCE account (InpRole = SOURCE), it never closes a position just because it is open and matches a magic filter - every single ticket must be explicitly listed by number in InpConfirmedTickets, and even then nothing happens unless InpArmMigration is also set to TRUE. Left unarmed, it only prints a dry-run list of eligible ticket numbers so the trader can review and copy them into the confirmed list deliberately. For each ticket actually confirmed and armed, it closes the position, then writes a row to a shared manifest recording the symbol, direction, lots, and each stop's distance in POINTS (not a raw price, which means nothing on a different account) - and immediately appends a plain-language rollback note explaining that the original fill can no longer be replicated and what to manually re-open if the migration needs undoing. On the TARGET account (InpRole = TARGET), it reads that manifest and, for every row still pending, opens the equivalent position sized to THIS account's own live lot step/min/max (never the source account's lot size verbatim) with stops re-derived from the recorded point distance against this account's own current price. If the target-side open fails, the manifest is marked FAILED and a rollback note records plainly that the position now exists on NEITHER account and needs manual attention - the migration is never silently retried or auto-reversed. Notes and limitations - This is NOT atomic. Between a SOURCE close succeeding and the TARGET open completing, the position genuinely exists on neither account. This gap is inherent to migrating between two separate trade servers - there is no way to close and open in a single transaction across them - and it is exactly why every step is logged with a rollback note rather than assumed to always succeed. - "Rollback" is honest, not literal: a closed source position cannot be reopened at its original price and time. The rollback notes describe what to manually re-enter as a NEW trade, not a true undo. - Stops are migrated as a POINT distance from the source's own open price, re-applied against the target's own current price at open time - the resulting stop level is equivalent in distance, not in absolute price, and is still subject to the target broker's own stop-level/ freeze-level constraints. - Tracks at most 200 manifest rows in memory per run per side (a documented fixed-array cap, MAX_TRACKED_TICKETS in the source); migrate in batches within that limit. - On MQL5 netting accounts, TARGET refuses to open into a symbol that already carries a foreign-magic position rather than risk merging into it - see MQL4 VERSUS MQL5 DIFFERENCES. Clear or reassign that position first if this happens. - Assumes the source and target accounts trade the same symbol NAME. If the two brokers use different symbol naming, resolve that separately (see the Auto Learning Symbol Mapper project elsewhere in this catalogue) before running a migration - this EA does not remap symbol names itself. - Reimplements its own lot normalisation and shared-file append pattern inline rather than including another project's file, per this catalogue's no-cross-project-include rule.
Expert advisor · MT4 · v1.0 · Free
About Account Migration Executor
Account Migration Executor is an expert advisor (trading robot) for MetaTrader 4. It has 8 settings, such as Role, Migration tag and Arm migration. MQL source code included.
Files in the download: AccountMigrationExecutor.ex4, AccountMigrationExecutor.mq4, AccountMigrationExecutor.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 |
|---|---|---|
| Role | ROLE_SOURCE | Which side of the migration this chart plays |
| Migration tag | Shared manifest filename tag; SOURCE and TARGET must use the SAME tag; blank = auto from SOURCE's ac | |
| Arm migration | false | Must be explicitly TRUE on the SOURCE side, or this run only logs a dry-run report and closes nothin |
| Confirmed tickets | SOURCE: comma-separated exact ticket numbers to migrate this run - nothing else is touched, even if | |
| Magic filter | 0 | SOURCE: 0 = any magic eligible; otherwise only list/migrate this magic number |
| Slippage points | 30 | SOURCE: slippage tolerance for the migration close; TARGET: slippage tolerance for the migration ope |
| Target magic number | 47900 | TARGET: magic number stamped on the newly-opened migrated positions |
| Poll interval sec | 5 | Seconds between manifest scans |
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: Risk & Lot Size · MT4 Expert Advisor · MQL4 Source Code