Discussing the article: "Comparing Trade Return Distributions with Mann-Whitney U in MQL5"

 

Check out the new article: Comparing Trade Return Distributions with Mann-Whitney U in MQL5.

A native, dependency-free MQL5 implementation of the Mann-Whitney U test for comparing trade returns across two market regimes. It details rank calculation, tie correction, and a normal-approximation p-value, and pairs the test with a CCanvas box-and-whisker chart and a trade-history extraction script. A verification script is included, and the limits of the normal approximation and independence assumptions are clearly stated for informed use.

A common practice when evaluating a trading strategy across two market periods is to compute the average return in each period and compare the two numbers. This comparison is fast and intuitive, but it is statistically unreliable for trade return data. Trade returns are skewed by asymmetric win/loss structures, exhibit fat tails from slippage and gap events, and are frequently dominated by a handful of outlier trades that pull the mean away from where the bulk of the distribution sits. Two periods can have nearly identical mean returns while having distributions that look nothing alike.

MQL5 has no built-in non-parametric test for comparing two return samples without assuming a distribution shape. This article builds one. The implementation has three components:

  • CMannWhitneyTest: pools both samples, assigns ranks, computes the U statistic with tie correction, and derives a z-score and p-value
  • CBoxPlotRenderer: draws a dual box-and-whisker chart on a shared canvas so the two distributions are directly comparable by eye
  • MannWhitneyDemo: extracts per-trade returns from closed trade history and connects the two components above

The full workflow is: ExtractReturns pulls two date-windowed return samples from the terminal's trade history, CMannWhitneyTest performs the statistical test, CBoxPlotRenderer plots the result, and the demo script connects all three. The complete source files are included in the archive attached at the end of the article.

Mann Whitney architectural diagram

Author: Ushana Kevin Iorkumbul