Loading…

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 · MT4 · v1.0 · Free

About Copy Chain Compliance Logger

Copy Chain Compliance Logger is a script for MetaTrader 4. It has 5 settings, such as Audit log name, Chain delimiter and Magic filter. MQL source code included.

Files in the download: CopyChainComplianceLogger.ex4, CopyChainComplianceLogger.mq4, CopyChainComplianceLogger.txt.

Settings

SettingDefaultWhat it does
Audit log namecopy_chain_compliance_log.csvFile in MQL4\Files\ this EA appends the audit trail to
Chain delimiter|Character separating chain hop tokens inside the order comment
Magic filter00 = audit every own-account trade; otherwise only this magic
Poll interval sec2Seconds between scans for new/closed trades
Max tracked trades200Cap on simultaneously tracked open tickets (fixed-size, see .txt)

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 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: Buy/Sell Arrows · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria