How Many Trades Before Your Backtest Means Anything? A Statistical Check in MQL5

24 November 2026, 15:57
Frederic Jean Andre Jouillerot
0
8

A backtest with 100 trades and a profit factor of 1.3 looks like a working strategy. It may be nothing at all. Below a certain number of trades, a system with zero edge produces "good" reports surprisingly often. This post quantifies how often, and gives an MQL5 snippet to check whether your own results are distinguishable from noise.

1. A system with no edge, simulated 10,000 times

Synthetic example, not a real EA: 40% winners at +1.5R, losers at -1R. Expectancy is exactly zero. We generate 10,000 independent backtests of this system at different sample sizes and count how many look profitable.

  • 100 trades: 8.8% of runs show a profit factor of 1.3 or more, 17.2% show 1.2 or more. The best run reaches 2.07.
  • 200 trades: 3.6% reach 1.3 or more.
  • 500 trades: 0.1% reach 1.3 or more.
  • 1,000 trades: none reach 1.3. The best run is 1.27.

A coin-flip system with a "decent" profit factor is common at 100 trades and becomes rare only in the high hundreds.

2. Optimization makes it much worse

Nobody tests one variant. Test 20 parameter sets of a system with no edge on 100 trades each, and the chance that at least one of them shows PF 1.3 or more is about 84% (1 - 0.912^20). The optimizer will find it, and it will look like a discovery.

This is the core of curve fitting: the more variants you try on a small sample, the more certain you are to find a lucky one.

3. How many trades does a real edge need?

Take a modest real edge: +0.1R per trade (44% winners at +1.5R). The per-trade standard deviation is about 1.24R. To get the average two standard errors away from zero, you need roughly (2 x 1.24 / 0.1)^2, about 600 trades. With 100 trades, that same real edge is statistically indistinguishable from zero.

The smaller the edge, the larger the sample: the required number of trades grows with the square of (volatility / edge).

4. A quick check in MQL5

Put your closed trades in R (profit divided by initial risk) in an array, then compute the expectancy, its standard error and a t-statistic:

void OnStart()
  {
   double r[];    // fill with your trade results in R
   int n = ArraySize(r);
   if(n < 2) { Print("Not enough trades"); return; }

   double sum = 0;
   for(int i=0; i<n; i++) sum += r[i];
   double mean = sum / n;

   double ss = 0;
   for(int i=0; i<n; i++) ss += (r[i]-mean)*(r[i]-mean);
   double sd = MathSqrt(ss / (n-1));
   double se = sd / MathSqrt(n);
   double t  = (se > 0) ? mean / se : 0;

   PrintFormat("Trades: %d  Expectancy: %.3fR  SE: %.3fR  t: %.2f",
               n, mean, se, t);
   PrintFormat("Trades needed for t=2 at this edge: %.0f",
               (mean > 0) ? MathPow(2*sd/mean, 2) : 0);
  }

Rough reading: a t below 2 means the result is compatible with no edge. Above 2 is a start, not a proof, especially if many variants were tested (see section 2).

5. Limits of this check

  • Independence. The formula assumes trades are independent. Clustered losses in specific regimes widen the real uncertainty.
  • Stationarity. A significant result over 2015-2020 says nothing certain about 2027. Out-of-sample and walk-forward tests remain necessary.
  • Multiple testing. The t-statistic of the best of 50 optimized variants is inflated. Validate on data the optimizer never saw.

6. How we apply it

At Pipmaster France, this is why we ask anyone evaluating Titan Breakout, our H1 breakout EA, to backtest it over several years and several symbols before drawing any conclusion: a few months of H1 breakouts gives dozens of trades, not the hundreds the statistics need. It is free to download for backtesting and demo, so you can run this check on its trades with your own broker data: Titan Breakout (free backtest and demo).

The figures above come from a synthetic simulation (10,000 runs, fixed seed), not from any real strategy or account. Trading leveraged products involves a high risk of capital loss. Past or simulated results do not guarantee future performance.