Discussing the article: "Do My EA's Losses Come in Clusters? A Wald-Wolfowitz Runs Test for Trade Outcomes in MQL5"

Check out the new article: Do My EA's Losses Come in Clusters? A Wald-Wolfowitz Runs Test for Trade Outcomes in MQL5.

A pause after a losing streak assumes that losses come in clusters. CRunsTest turns the closed trades of an account or a tester run into a sequence of wins and losses and checks it with the Wald-Wolfowitz runs test, streak checks against shuffled orders, and a drift test. No dependence was detected on the tested EAs. A power simulation shows which effects each check could see, and on the shorter test runs a "not detected" result carries little weight.

In an earlier article I built a per-setup trade ledger. It put a Wilson interval around the win rate of each entry type in an EA. In the review the moderator asked what assumptions that interval rests on. The interval treats the trades as Bernoulli trials: each trade wins with the same probability, and the result of one trade tells you nothing about the result of the next. I understood both conditions. I had never checked either of them on my own trades.

The second condition also sits under a rule I see in many EAs and trading plans. Stop for the day after 3 losses in a row, or cut the lot after a loss. A pause like this can serve several purposes, such as a daily loss limit or a cooling-off period for the trader. This article looks at one purpose only, the idea that the trade after a losing streak is more likely to lose. As a filter of that kind, the rule only helps if losses come in clusters. If they don't, the pause skips trades with the same chance of winning as any other trade.

Two articles on this site already point at the gap. Kayode Michael Oyetunde's article on hypothesis testing [1] warns that win and loss streaks make p-values look better than they are. The Monte Carlo stress test article [2] says it does not model serial correlation between trades. Neither of them tests for it.

This article implements the test as a small set of include files. They read the closed trades of an account or a tester run and convert them into a win/loss sequence in the order the trades closed. The Wald-Wolfowitz runs test [3] is applied to that sequence. Because traders think in streaks more than in runs, the module adds three streak checks: the longest losing streak, the loss rate of every trade after 3 or more losses, and the loss rate of the first trade after exactly 3 losses. Each check is compared with 10,000 shuffled orders of the same trades. A fourth check tests the other condition, a win rate that stays the same over time.

Author: Ali Akbar