Discussing the article: "Custom Debugging and Profiling Tools for MQL5 Development (Part II): Profiling EAs and Testing Trading Logic"

 

Check out the new article: Custom Debugging and Profiling Tools for MQL5 Development (Part II): Profiling EAs and Testing Trading Logic.

We build a compact profiler that records calls, min/max/average times, and slow-call counts to CSV, and a simple test runner that writes deterministic pass/fail reports. The article explains where to place measurements in an EA, how to sample ticks, and how to keep pure calculations testable. Running the script first and the profiling EA second provides repeatable evidence for regression analysis.

Logs tell the story of an event. They are good at answering questions such as "Did the EA enter this branch?" or "Why was an order blocked?" They are much weaker at answering questions about repeated costs. If CopyBuffer() becomes slightly slower across thousands of calls, a plain log gives noise; a profiler gives count, total time, min, max, and average. Correctness has a similar problem: a log can say that a buy signal was detected, but it cannot prove that the buy signal came from the intended rule.

A moving average crossover can look reasonable in the Experts tab while using the wrong bar index. A volume rule can pass most symbols and still fail at the broker minimum. A stop-distance check can work on a five-digit forex symbol and fail on a two-digit metal quote. For those cases, it helps to separate three kinds of evidence:

  • Logging is observation: it records what the program says it did.
  • Profiling is measurement: it records how often selected work happened and how expensive it was.
  • Unit testing is verification: it checks whether selected rules still return expected results for fixed inputs.


Author: Sahil Bagdi