Loading…

File Bridge Command Consumer

A common pattern is an external process (a Python script, a webhook relay, a phone-triggered automation) that wants to tell a running EA to do something - close all trades, pause, change a parameter - by dropping a small text file into the terminal's sandboxed Files folder. The naive version of "read whatever file shows up and act on it" trusts anything that lands there, which means anything with write access to that folder (a bug in the writer, a misconfigured second process, or a genuine attacker) can command the EA directly. This header requires every command file to carry an HMAC-MD5 signature and rejects anything that does not verify - unsigned, mis-signed, or tampered content is reported back with a reason, never silently acted on. It reuses this catalogue's MessageSigningVerification.mqh signing pattern: a hand-written MD5 core (RFC 1321) with a genuine HMAC construction (RFC 2104) on top, duplicated here under an Fbc- prefix rather than #included from that other project, because every submission in this catalogue must stand alone. FbcPollCommands() scans the sandbox for files matching a glob pattern (e.g. "cmd_*.txt"), verifies and parses each one, and consumes (deletes) it exactly once regardless of whether the signature was valid - a rejected file is reported to the caller once and then gone, so a bad or replayed file can never sit in the folder being reprocessed forever. FbcCommand uses fixed-size parameter arrays rather than dynamic ones, which keeps it a safe plain value type that can be stored directly in an output array with ordinary struct assignment. Notes and limitations - Same honest security note as MessageSigningVerification.mqh: HMAC-MD5 is a genuine, unbroken message-authentication construction, but MQL4 has nowhere secure to store the shared key - this defends against a corrupted or tampered command file, not against an attacker who already has file-system access to the machine the key lives on. - Command files are assumed single-line, one command per file - the reader only looks at the first line, which is also what makes delete-on-consume safe without a partial-write race. - No replay protection beyond "the file is deleted after one read" - a determined external writer could recreate the same signed file again. Add a nonce or timestamp field inside the signed portion and check it yourself if replay resistance across process restarts matters for your use case. - FBC_MAX_PARAMS caps a command at 16 key=value fields; anything beyond that is silently not stored (the command name and first 16 params are still parsed correctly).

Script · MT5 · v1.0 · Free

About File Bridge Command Consumer

File Bridge Command Consumer is a script for MetaTrader 5. It has 1 setting, such as Shared key. MQL source code included.

Files in the download: FileBridgeCommandConsumer.mq5.mqh, FileBridgeCommandConsumer.txt, FileBridgeCommandConsumerDemo.ex5, FileBridgeCommandConsumerDemo.mq5.

Settings

SettingDefaultWhat it does
Shared keydemo-shared-secret-change-mekey used to sign/verify the demo command files

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 → Scripts.
  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 script onto a chart to run it once.

Download the PDF guide

Tags: MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria