Skip to content
All library documents

Calculating Trading Statistics and Equity Drawdown During Testing

Article MQL5 code base

Summary

The document describes a class for calculating trading statistics from trade history, including while a strategy is running or outside the strategy tester. It presents this as a way to access statistics without relying on the tester-only statistics function. After calculation, users can retrieve individual measures or print the full set to a log.

Equity drawdown is handled separately: it must be updated through dedicated calls at initialization, on ticks, and at shutdown. The document also shows refreshing other statistics after trades, with a time check to avoid repeated updates in the same second. It gives an example output for a linear regression correlation and points to sample scripts and a visualization panel. These examples explain usage, but the document does not define the individual statistics, assess their reliability, or provide trading results; the drawdown calculation also requires its own update cycle.

Key ideas

  • Trade history can provide many strategy statistics outside the strategy tester.
  • A calculation call updates the values made available through the class.
  • Equity drawdown requires separate updates during the strategy lifecycle.
  • Trade events can trigger refreshed statistics, with repeated same-second calls suppressed.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.