Execution Quality Report
Almost every EA logs whether its send call succeeded and stops there. It never records what price the strategy WANTED versus what price the broker actually filled, how long the round trip took, or how many times the request came back requoted before it finally went through. Without those three numbers, "slippage", "latency" and "requote rate" stay forum-post words instead of something measured for this account, this broker, this time of day. BeginAttempt captures the decision price and starts a millisecond timer the instant before the send call is made, using GetTickCount rather than TimeCurrent - TimeCurrent only has one-second resolution on both platforms, and most fills complete faster than that, which would round every latency to zero or one second and hide the number that actually matters. CompleteFilled or CompleteFailed close the attempt and compute slippage in points and latency in milliseconds from what BeginAttempt captured. Slippage uses a signed convention that stays meaningful when averaged across both directions: positive always means "worse than the decision price", whichever way the trade went. A buy filled above the decision price is positive slippage; a sell filled below it is also positive slippage. Without this convention, buys and sells slipping in their respective adverse directions would partially cancel out in a naive average and understate how bad execution actually is. RecordRequote is a plain counter, called once per requote encountered inside whatever retry loop the caller already runs - neither platform hands the library an automatic requote event, so the caller flags it explicitly. Aggregate methods - AverageSlippagePoints, MaxSlippagePoints, AverageLatencyMs, MaxLatencyMs, RequoteRate, FillRate - summarise everything recorded so far. ExportCsv writes the full per-attempt detail to the sandbox for a durable audit trail beyond what fits in the terminal journal. Notes and limitations - This library measures; it never sends, modifies or closes an order itself on either platform. - Latency is measured from BeginAttempt to CompleteFilled/CompleteFailed, so it only reflects the time the CALLER'S code takes between those two calls - if the caller does other work in between, that time is counted too. - The requote count relies entirely on the caller invoking RecordRequote; the header has no way to detect a requote on its own on either platform. - Data is kept in memory only until ExportCsv is called. A terminal restart loses anything not yet exported - export periodically in a live EA, not only at the end of a run. - Slippage is computed from the symbol's point value, so it is comparable across symbols with the same digit count but not necessarily across symbols with different quote precision without converting to a common unit first. - MQL5's failureCode field stores a TRADE_RETCODE_* value, not a GetLastError() code - passing a raw GetLastError() value into CompleteFailed on the MQL5 side will produce a meaningless "unlisted retcode" description if decoded with TradeRetcodeDescription. Always pass the trade result's own retcode.
Script · MT4 · v1.0 · Free
About Execution Quality Report
Execution Quality Report is a script for MetaTrader 4. It has 3 settings, such as Simulated attempts, Simulated delay ms and Csv file. MQL source code included.
Files in the download: ExecutionQualityReport.mqh, ExecutionQualityReport.txt, ExecutionQualityReportDemo.mq4.
Settings
| Setting | Default | What it does |
|---|---|---|
| Simulated attempts | 8 | How many fake attempts to generate |
| Simulated delay ms | 40 | Artificial latency per attempt, milliseconds |
| Csv file | ExecutionQualityReportDemo.csv | Sandbox export filename |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Arbitrage · MT4 Script · MQL4 Source Code