Skip to content
All library documents

Measuring Expert Advisor Quality with Trade Statistics

Article MQL5 articles

Summary

This article explains how an MQL5 Expert Advisor can return a custom quality value to the strategy tester through its OnTester function. To demonstrate the process, it builds a deliberately random-entry system with minimum-lot trades, a time window, and a stop that moves as new candles form. The trading rules are an implementation example rather than a proposed source of trading edge.

The article first calculates an average reward-to-loss measure from gross profit and gross loss, normalized by the counts of winning and losing trades, with adjustments to avoid division by zero. It also introduces Van Tharp and Sunny Harris quality calculations and describes using preprocessor definitions and an include file to switch between alternative OnTester implementations. The example reports a tester result, but the supplied text does not give a meaningful comparison of the metrics or establish that any score predicts future performance. These values summarize selected historical trade statistics; they depend on the chosen formula and test sample and should not be treated as standalone evidence of strategy quality.

Key ideas

  • An Expert Advisor can return a custom scalar to the strategy tester through OnTester.
  • A random-entry Expert Advisor can serve as a code example for testing metric calculations.
  • The article derives an average reward-to-loss measure from gross outcomes and trade counts.
  • Separate metric implementations can be selected through an include file and preprocessor definitions.
  • A historical quality score does not by itself show that a strategy will perform well in future data.

Tags

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