Copy Chain Compliance Logger
A compliance or audit programme reviewing copied trading activity usually needs more than "a trade happened" - it needs to show where the trade came from: which signal provider, which bridge, which local EA actually pressed the button. MT4's own trade history carries none of that by default; a closed order looks identical whether it was placed manually or copied through three hops. This EA does not invent a new signalling protocol. It works from a documented convention: any upstream EA in a copy chain that wants its hop recorded appends a short tag to the order comment, separated from the next hop's tag by a configurable delimiter (default the pipe character). This logger reads that comment on both order OPEN and order CLOSE, splits it into hop tokens, and writes a full audit row - ticket, event, symbol, direction, lots, magic number, hop count and the joined chain itself - to a CSV file suitable for feeding into a compliance programme's own review tooling. An order comment with no delimiter is not treated as "no chain data" - it is logged as a single untagged hop, so the absence of tagging is itself visible in the audit trail rather than silently dropped. Notes and limitations This logger can only record what is actually present in the order comment. If an upstream EA does not stamp chain hops into the comment using the agreed delimiter convention, there is no way to reconstruct the chain retroactively - every trade from that source is logged as a single untagged hop, honestly, rather than guessed at. The order comment field has MT4's usual length limit (well under 32 characters is safe in practice); a very long chain of many verbose hop identifiers can be truncated by the terminal before this EA ever sees it. Keep hop tags short. The tracking table is a fixed-size array capped at 200 simultaneously open tracked tickets (InpMaxTrackedTrades cannot exceed this). A new ticket arriving while the table is full has its OPEN record skipped (and the skip itself logged to the Experts tab) until a tracked slot frees up on a later scan - it is not queued or backfilled. This is a read-only observer. It never modifies, opens or closes any order itself, and places no trades of its own - it only watches and logs whatever the account's other EAs, or the terminal's own manual trading, produce. A partial close creates a brand-new ticket for the remaining volume rather than leaving it under the original ticket; this logger records that as its own separate OPEN event on a later scan, since from the order pool's point of view it genuinely is a new ticket.
Expert advisor · MT5 · v1.0 · Free
About Copy Chain Compliance Logger
Copy Chain Compliance Logger is a script for MetaTrader 5. It has 5 settings, such as Audit log name, Chain delimiter and Magic filter. MQL source code included.
Files in the download: CopyChainComplianceLogger.ex5, CopyChainComplianceLogger.mq5, CopyChainComplianceLogger.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Audit log name | copy_chain_compliance_log.csv | File in MQL5\Files\ this EA appends the audit trail to |
| Chain delimiter | | | Character separating chain hop tokens inside the position comment |
| Magic filter | 0 | 0 = audit every own-account trade; otherwise only this magic |
| Poll interval sec | 2 | Seconds between scans for new/closed trades |
| Max tracked trades | 200 | Cap on simultaneously tracked open tickets (fixed-size, see .txt) |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Buy/Sell Arrows · MT5 Expert Advisor · MQL5 Source Code