Logging every OrderSend return code: what to capture
Posted: Thu Oct 29, 2026 6:21 pm
Many EAs log only successful trades. That makes a missed entry impossible to explain afterwards. Logging every OrderSend result, including the retcode, the requested price and the time taken, fixes that.
What to capture per request on MT5:
For execution time, look at the median and the slowest 1%, and check whether the slow ones cluster in news minutes.
If your EA only logs success, you have no idea what you're missing. Does anyone log more fields than these?
What to capture per request on MT5:
- Retcode from MqlTradeResult, plus the comment.
- Requested price and the bid/ask at the time.
- Milliseconds from send to result.
- Spread and whether news was within a few minutes.
- Most requests done on the first attempt.
- Some "price changed" or requotes (TRADE_RETCODE_REQUOTE, TRADE_RETCODE_PRICE_CHANGED), usually clustered at the open and around data.
- Occasional "no prices" during brief disconnections.
- "Invalid stops" (TRADE_RETCODE_INVALID_STOPS), which are usually your own bug: a stop inside the stops or freeze level after a spread spike.
For execution time, look at the median and the slowest 1%, and check whether the slow ones cluster in news minutes.
If your EA only logs success, you have no idea what you're missing. Does anyone log more fields than these?