File Based Terminal Messaging
Neither platform has an inter-process signalling primitive, so anything wanting to pass a signal between two EAs - or between EAs running in different terminal instances - has to go through the file system. The obvious design is one shared file per channel that senders append to and readers poll, but neither platform gives a safe way to do that concurrently: there is no share-mode flag that lets two writers interleave an append safely, and a reader can catch the file mid-write and see a truncated or duplicated line. This header avoids the problem instead of trying to solve it: every message is its own uniquely named file. Sending is a single create-write-close that never opens anything another program might be touching. Receiving lists the channel's folder, reads each file found, and deletes it once delivered - a single-file read-then-delete per message rather than a shared read-modify- write. Both operations are things the file system already makes atomic on their own, so there is no lock file, no retry loop and no window where a reader can observe a half-written message. Filenames encode GetTickCount() and a monotonic per-process counter, so FileMsgReceiveAll() delivers messages in the order they were sent simply by sorting filenames alphabetically - no separate sequence file to maintain. Messages can go through the private per-terminal sandbox or the shared common Files folder (FILE_COMMON) that every terminal on the machine can see, which is what makes cross-terminal signalling possible at all. Notes and limitations - Delivery order relies on GetTickCount(), which wraps after roughly 49 days of continuous uptime on both platforms; the per-process counter appended to every filename still guarantees uniqueness across that wrap, only the strict chronological ordering guarantee weakens right at the wrap boundary. - This is at-most-once delivery with no acknowledgement and no retry: if a receiver crashes after FileMsgReceiveAll() reads a message but before it acts on it, that message is already deleted and gone. Use deleteAfterRead=false plus your own acknowledgement scheme if a message must survive a receiver crash. - No message size limit is enforced; very large payloads work but are read entirely into memory as one string. - FILE_COMMON messages are visible to every terminal on the machine that shares the same common Files folder - do not use a common-folder channel name generic enough that an unrelated EA on the same PC might collide with it (e.g. prefix with your strategy's name, as the demo does).
Script · MT4 · v1.0 · Free
About File Based Terminal Messaging
File Based Terminal Messaging is a script for MetaTrader 4. It has 2 settings, such as Channel and Common folder. MQL source code included.
Files in the download: FileMessaging.mqh, FileMessaging.txt, FileMessagingDemo.mq4.
Settings
| Setting | Default | What it does |
|---|---|---|
| Channel | FileMsgDemo_Signals | Channel name, becomes a subfolder under Files\ |
| Common folder | false | true = shared across every terminal on this PC |
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 → Scripts.
- 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 script onto a chart to run it once.
Tags: Channels & Envelopes · Buy/Sell Arrows · MT4 Script · MQL4 Source Code