Discussing the article: "Auditing an Expert Advisor From Its Trade History (Part 1): Rebuilding Positions From Deals"

Check out the new article: Auditing an Expert Advisor From Its Trade History (Part 1): Rebuilding Positions From Deals.

This article introduces TradeAudit, an MQL5 include library that rebuilds closed trades from raw deal history to produce one consistent record per trade. It handles partial closes, scale-ins on netting accounts, netting reversals, close-by pairs, and positions spanning the date range. A script exports the records to CSV, and a self-test script runs synthetic netting and close-by sequences. The result is a clean per-trade dataset for reliable EA statistics and verification.

When deciding whether to keep running an Expert Advisor, the first place to look is its history: how many trades it took, how many of them won, what an average trade earned. A program that computes those figures has to read the account's history in MQL5, where every entry, every partial exit and every reversal is stored as a separate deal. A trade is something the program has to rebuild from those deals.

This article uses the word trade for one unit: on a hedging account one position, and on a netting account one segment of a position, from its first entry until the volume returns to zero or a reversal turns it. The library builds one record for each. That unit is a choice. The terminal's report in the Verification section gives a trade count equal to its number of closing deals, and a close-by, one operation for the trader, is two trades here because it closes two positions. A figure counted per trade has to say which unit it uses.

Author: Solomon Anietie Sunday