Monte Carlo reshuffling and autocorrelation
The common Monte Carlo test for a backtest takes its trades, shuffles their order thousands of times and reports how deep the drawdown gets. It answers a narrower question than most people read into it, and when good and bad trades come in clusters, it answers even that one too optimistically.
What reshuffling measures
A reshuffle keeps every trade and changes only the order. The final result is identical on every path; only the route to it changes. So the test measures order risk: how much worse the drawdown could have been with the same trades arriving in a different sequence.
Two assumptions sit underneath it:
- Trades are exchangeable. Any order is as likely as any other. That is true when each trade is independent of the previous ones.
- The trades are the truth. The test never considers that the strategy could have had fewer winners than it happened to have. The uncertainty of the edge itself is outside it.
Where independence fails
Many strategies have good and bad periods: a trend follower in trending and ranging markets, a mean-reversion system before and after a volatility shift. Losses then arrive in clusters. Shuffling breaks the clusters up and spreads the losers evenly through the history, which is exactly the situation that does not produce deep drawdowns.
The dependence does not have to be large to matter. A correlation between consecutive trades of a few hundredths is hard to see and easy to miss in a test, yet it can change drawdown risk a lot when it persists over dozens of trades.
A simulation you can reproduce
We generated trade results in units of risk (R) from two regimes. In a good regime a trade averages +0.30R, in a bad one −0.30R, both with a standard deviation of 1R, and after each trade the regime switches with probability 4%, so a regime lasts about 25 trades; the first regime is chosen at random. On average the edge is zero. The correlation between consecutive trades is small: its median over the histories was 0.07.
We drew 400 histories of 500 trades and, for each, estimated the 95th percentile of the maximum drawdown with four methods, 2,000 paths each. The reference is the same percentile over 20,000 fresh histories from the process itself. As a control we repeated everything with independent trades of the same variance. Drawdown is measured on cumulative R, without compounding. Everything needed to repeat it is in this paragraph; our run used NumPy’s default generator with seed 20261123, fixed before the run.
| Method | Clustered trades | Independent trades |
|---|---|---|
| True value (fresh histories) | 82.3 | 50.5 |
| Shuffle single trades | 38.7 | 37.6 |
| Shuffle blocks of 8 trades | 45.1 | 36.4 |
| Shuffle blocks of 25 trades | 52.3 | 36.1 |
| Stationary block bootstrap, mean block 25 | 71.9 | 48.4 |
Three things follow.
- Shuffling cannot see the clusters. It gives about 38R whether the trades are clustered or independent, while the true risk is 82R in one case and 50R in the other.
- Shuffling also misses the uncertainty of the total. Even with independent trades it falls short, 37.6R against 50.5R, because every path ends where the backtest ended. Sampling trades with replacement, as a bootstrap does, lets the total vary and comes close: 48.4R.
- Blocks recover the clustering only partly. Reshuffling blocks keeps the trades inside each block together; longer blocks keep more of the clustering. Combined with resampling, the stationary block bootstrap of Politis and Romano (1994) gets closest, and still falls short, because one history of 500 trades contains only a handful of regimes.
These are numbers for one constructed process, not a rule for every strategy. They show the direction and the size the error can have.
Checking your own trades
- Runs test. Do wins and losses come in runs? The Z-Score in the MetaTrader 5 report is this test; beyond about ±2 the order is unlikely to be random.
- Ljung–Box test on trade results and on their absolute size. The second catches calm and turbulent stretches even when wins and losses alternate normally.
- Look at the equity curve by period. Long flat or falling stretches between good ones are clustering, whatever the tests say on a short sample.
If any of these point to dependence, a single-trade shuffle understates drawdown. A block method is better, and it is still an estimate from one history.
Choosing the block length
Too short and the clusters are cut; too long and there are few blocks to recombine, so the paths barely differ. A common rule of thumb grows the block with the cube root of the number of trades: 8 for 500 trades. Politis and White (2004, with a correction by Patton, Politis and White, 2009) give a way to estimate it from the data. The table shows why the choice matters: blocks of 8 recovered a little of the gap, blocks of 25, about the length of a regime, more.
How we do it
Our reports reshuffle the trades 2,000 times and show the median, 95th and 99th percentile drawdown. When the runs test or the Ljung–Box test finds dependence, we reshuffle blocks of ⌈n1/3⌉ trades instead of single trades. Like any reshuffle, this keeps the total of the backtest fixed, so the report states it as drawdown for these trades in another order, not as a forecast. Whether the edge itself is real is a separate test: the probabilistic Sharpe ratio. See the methodology or check your file for free.
Sources
- Künsch, H. R. (1989). The Jackknife and the Bootstrap for General Stationary Observations. Annals of Statistics, 17(3).
- Politis, D. N. and Romano, J. P. (1994). The Stationary Bootstrap. Journal of the American Statistical Association, 89(428).
- Politis, D. N. and White, H. (2004). Automatic Block-Length Selection for the Dependent Bootstrap. Econometric Reviews, 23(1); correction: Patton, A., Politis, D. N. and White, H. (2009), Econometric Reviews, 28(4).
- Ljung, G. M. and Box, G. E. P. (1978). On a Measure of Lack of Fit in Time Series Models. Biometrika, 65(2).