Zero-DLL MT4 to MT5 Local Trade Copying: Atomic FILE_COMMON Architecture and Benchmarks

3 December 2026, 03:44
Meng Chang Chen
0
12

Traders operating multiple MetaTrader 4 and MetaTrader 5 terminals on the same VPS or managing funded prop accounts often face a difficult choice: pay recurring monthly fees for cloud relay copiers that add network latency, or install unverified external Windows DLL libraries that introduce security and compliance risks.

MetaTrader 4 and MetaTrader 5 already share an official, sandboxed, zero-DLL inter-process directory built directly into the platform: FILE_COMMON ( %APPDATA%\MetaQuotes\Terminal\Common\Files\ ).

1. Why Atomic Snapshot Swapping Beats Naive CSV Copiers

Basic local copier scripts overwrite a single shared CSV file in place. When a Slave terminal polls every 100 ms, it can occasionally read a half-written file and trigger false closes or duplicate entries.

An atomic FILE_COMMON architecture eliminates partial-read corruption completely:

  • The Master writes the complete unified state (platform tag, account equity, UTC timestamp, monotonic sequence counter, and all open positions) into a temporary file.
  • The Master swaps it into place in one OS-level call using FileMove(tmpFile, FILE_COMMON, snapshotFile, FILE_COMMON | FILE_REWRITE) .
  • Slave terminals verify sequence integrity and heartbeat freshness before synchronizing entries, SL/TP updates, proportional partial closes, and full exits.

2. Measured Native MT5 Benchmarks (Zero DLL)

We benchmarked atomic FILE_COMMON serialization directly inside MetaTrader 5 Build 6302 across 1 to 100 simultaneous positions:

  • 1 open position (152 B binary + CRC32): mean read latency 104.3 microseconds (0.10 ms), 100.00% integrity pass.
  • 10 open positions (1,016 B binary + CRC32): mean read latency 141.6 microseconds (0.14 ms), 100.00% integrity pass.
  • 100 open positions (9,656 B binary + CRC32): mean read latency 268.8 microseconds (0.27 ms), 100.00% integrity pass, 100% exact 64-bit ticket preservation.

3. Three Engineering Traps That Break Basic Cross-Platform Copiers

  • 64-bit MT5 ticket overflow in MT4: modern MT5 ticket numbers exceed 32-bit integer limits. Parsing them with StrToInteger() in MT4 causes silent truncation; 64-bit StringToInteger() is mandatory.
  • Broker symbol suffix and alias mismatches: Gold and index feeds vary across brokers ( XAUUSD , XAUUSDm , GOLD.raw , USTEC , NAS100 ). Automatic suffix stripping and alias mapping prevent missed trades.
  • MT4 partial-close ticket splitting: partially closing an MT4 order closes the original ticket and spawns a new ticket tagged with "from #<oldTicket>". Without automatic split-ticket relinking, slave accounts orphan the remaining position.

4. Ready-to-Use Zero-DLL Institutional Utilities (Version 2.00)

All of these safeguards — alongside ECN filling-mode auto-detection, STOPS_LEVEL + FREEZE_LEVEL execution guards, and native anti-aliased CCanvas bilingual (EN/CN) interfaces — are built into our Version 2.00 utilities: