Discussing the article: "Engineering Trading Discipline into Code (Part 9): Building a Trade Activity Audit Trail in MQL5"

Check out the new article: Engineering Trading Discipline into Code (Part 9): Building a Trade Activity Audit Trail in MQL5.

Trade authorization controls what a cooperating Expert Advisor is permitted to send, but not every account action passes through that code. A trade may originate from the desktop terminal, a mobile device, the web terminal, or another Expert Advisor. This installment develops an independent auditor that records live transaction stages through OnTradeTransaction(), reconciles available historical orders and deals within a configured recovery window, and writes an account-bound CSV journal. An on-chart panel summarizes the selected period and provides refresh, detail, and export controls without modifying trades.

Part 8 completed a trade-authorization layer for a cooperating strategy. The strategy described its setup state, checked the active session, measured signal freshness, respected the global lock, and called the authorization function before placing a trade. That arrangement works because the strategy agrees to ask before calling OrderSend().

The trading account has a wider boundary. A trader can place an order from the desktop terminal, a mobile device, or the web terminal. Another Expert Advisor may use a different authorization system or none at all. A pending order may later execute because price reaches its trigger. A stop loss or take profit can close a position without the original entry program initiating a new market decision.

Those events are visible to the account even when they do not pass through the Part 8 strategy. They require a different component.

An account statement records the financial outcome. It does not always show the sequence that produced it. During a later review, the origin of an order may not be immediately clear. It may have come from the desktop terminal, a mobile device, an Expert Advisor, or an automatic protective level. Terminal messages help during operation, but they are not arranged as a persistent activity journal.

This matters even more when multiple terminals, clients, or programs share one account. Without a common record, distinguishing intentional, accidental, and system-generated positions depends on memory and scattered terminal information. The problem is therefore not simply whether a trade exists. It is whether the trader can reconstruct how it entered the account and connect it to the other stages of the same operation.

Author: Christian Benjamin