Zero-DLL Cross-Terminal IPC Pattern: Atomic FILE_COMMON Snapshots with FileMove() + 64-Bit Ticket Handling

Hello fellow MQL5 developers,

While building zero-DLL local bridges between MetaTrader 5 and MetaTrader 4 terminals on the same Windows VPS, I noticed that many older community examples still write directly to a shared CSV in FILE_COMMON — which occasionally causes half-written read collisions when a receiver polls every 100–200ms during fast news ticks.

Two simple MQL5 patterns completely eliminated those race conditions in our testing without touching Windows DLLs:

1. OS-Atomic Snapshot Swapping via FileMove()
Instead of overwriting the live snapshot file directly, write the full state to a temporary file first and swap it atomically:

   int h = FileOpen(tmpFile, FILE_WRITE | FILE_TXT | FILE_ANSI | FILE_COMMON);
   if(h != INVALID_HANDLE)
   {
      FileWriteString(h, payload);
      FileClose(h);
      FileMove(tmpFile, FILE_COMMON, liveSnapFile, FILE_COMMON | FILE_REWRITE);
   }

Because FileMove() with FILE_REWRITE performs an atomic rename inside Common\Files, polling terminals either read the complete previous snapshot or the complete new snapshot — never a truncated mid-write buffer.

2. 64-Bit MT5 Ticket Compatibility in Cross-Platform Parsers
Modern MT5 order/position tickets routinely exceed the 32-bit signed integer limit (2,147,483,647). When parsing wire payloads across MT5 and MT4, always parse ticket fields into 64-bit long using StringToInteger() rather than legacy 32-bit integer conversions.

Curious how other MQL5 engineers here benchmark zero-DLL IPC latency across multiple local terminals — are you using FILE_COMMON atomic snapshots, SQLite in Common\Files, or custom binary structs? Would love to hear your latency findings and edge cases!