Comparing Trade Return Distributions with the Mann–Whitney U Test
Summary
The article builds an MQL5 workflow for comparing trade returns from two date windows using the Mann–Whitney U test and box plots. It explains why means and t-tests can be misleading when trade returns are skewed or contain extreme losses. The rank-based test evaluates whether samples differ in distribution and whether one tends to rank above the other; it does not test equality of means. The implementation ranks pooled observations, averages ranks for ties, applies a tie correction, and approximates a two-sided p-value using a normal distribution.
A demo extracts closed-trade returns from terminal history, excluding zero-volume deals and other symbols while retaining valid breakeven trades. Its normalized return divides profit by volume and tick value, so it is not a conventional percentage return. The article recommends at least 20 observations per group for its normal approximation and says permutation testing is more reliable for smaller samples. The test can detect distributional differences but does not by itself establish that a strategy is profitable or that one period will predict the next.
Key ideas
- The Mann–Whitney U test compares pooled ranks and does not test whether two groups have equal means.
- Rank-based comparison limits the influence of an extreme observation to its rank, though it does not remove all distributional concerns.
- Tied observations receive average ranks, and the variance calculation is adjusted for ties.
- The MQL5 example compares filtered closed trades from two date windows and uses a normalized monetary return.
- The article advises caution with small samples and recommends permutation-based p-values below its stated sample-size guideline.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.