A backtest gives you one equity curve. It is the curve you get if every trade arrives in exactly the order history delivered it. Live trading will not repeat that order. The same kind of trades can arrive with the losers bunched together, and a strategy that looked calm on paper can spend months underwater.
Monte Carlo testing asks how much that matters. It takes the trades your strategy produced and rebuilds thousands of alternative histories from them, so you can see the range of drawdowns the same edge could have produced. This guide covers the main methods, how to run one in Python, how to read the output, and where the method stops being useful.
One point up front: Monte Carlo testing measures how fragile a set of results is to sequence and sampling. It does not tell you whether the trades themselves are real. If the backtest is overfit, Monte Carlo will faithfully reshuffle an overfit trade list. It reduces one kind of uncertainty; it does not reduce the risk of loss.
What a Monte Carlo test actually does
Every Monte Carlo method follows the same pattern. Take an input, usually the list of closed trades from a backtest. Randomly perturb it in a defined way. Rebuild the equity curve. Record the statistics you care about. Repeat a few thousand times, then look at the distribution of results instead of the single original figure.
The perturbation you choose decides what question you are answering. That choice matters more than the number of runs.
Three Monte Carlo methods and what each one tests
1. Trade reshuffling (permutation)
Keep every trade, change only the order. Because the same trades are present in every run, the final return is identical in every path if position size is fixed in currency, and identical when you compound by a fixed percentage too, since multiplication doesn't care about order. What changes is the path: the depth and length of drawdowns.
This is the cleanest test of sequence risk. It answers: "Was the backtest's drawdown typical, or did I get a lucky ordering?"
2. Resampling with replacement (bootstrap)
Build each path by drawing trades at random from the original list, allowing repeats, until the path has as many trades as the original. Some trades appear twice, some not at all. Now the final return varies as well as the drawdown, because each path holds a different mix of winners and losers.
This answers a broader question: "If the strategy's trade outcomes come from roughly this distribution, how wide is the range of results over a period this long?"
3. Perturbation of inputs
Rather than reorder trades, change the conditions that produced them: randomly skip a share of trades, add slippage noise to entries and exits, widen spreads, or nudge parameters and re-run the backtest. Some strategy-building tools offer these as built-in robustness checks.
This tests execution and parameter fragility rather than sequence. It overlaps with parameter sensitivity, which is covered in our guide to spotting an overfit backtest.
Which one should you use?
Use reshuffling first for drawdown risk, because it isolates sequence. Add bootstrap resampling to see how wide the return range is. Use perturbation when the strategy is sensitive to execution, such as short holding times or tight stops. Many validation workflows run more than one, and the approved sample report on this site used both reshuffling and resampling.
How to run a Monte Carlo test in Python
You need one input: a list of per-trade returns, expressed as a fraction of account equity at the time of the trade. Export closed trades from your platform, then convert profit or loss to a percentage of the balance before each trade. If you size every trade at a fixed percentage risk, R-multiples times that risk percentage give the same thing.
import numpy as np
def max_drawdown(equity):
peaks = np.maximum.accumulate(equity)
return ((peaks - equity) / peaks).max()
def monte_carlo(trade_returns, runs=5000, method="reshuffle", seed=42):
"""trade_returns: per-trade change in equity, e.g. 0.012 for +1.2%."""
rng = np.random.default_rng(seed)
r = np.asarray(trade_returns)
max_dds, finals = [], []
for _ in range(runs):
if method == "reshuffle":
sample = rng.permutation(r)
else: # "bootstrap": resample with replacement
sample = rng.choice(r, size=len(r), replace=True)
equity = np.concatenate([[1.0], np.cumprod(1 + sample)])
max_dds.append(max_drawdown(equity))
finals.append(equity[-1])
return np.array(max_dds), np.array(finals)
dds, finals = monte_carlo(trades, method="reshuffle")
print(np.percentile(dds, [5, 50, 95, 99]))
print((dds > 0.25).mean()) # share of paths with a drawdown beyond 25%
A few practical notes:
- Runs. A few thousand runs is usually enough for the median. Tail percentiles need more. Run the test twice with different seeds; if the 95th percentile moves noticeably between runs, increase the count.
- Fixed seed. Keep a seed in your saved results so you can reproduce a report exactly.
- Track more than maximum drawdown. Longest time underwater and the longest losing streak are often what make traders abandon a strategy, so record those too.
- Closed trades only see part of the risk. Trade-level Monte Carlo can't see floating losses inside an open trade. If your account rules are measured on equity, you need equity-level data as well. See testing an EA against prop-firm drawdown rules.
How to read Monte Carlo results
The output is a distribution. Read it in this order.
Step 1: Compare the median with the backtest
If the backtest drawdown sits near the middle of the simulated distribution, the original ordering was roughly typical. If the backtest drawdown sits near the best end, the backtest was a lucky sequence and the headline number understates risk.
Step 2: Look at the tail, not the average
The 95th and 99th percentiles describe the bad paths. Those paths are the ones that end a strategy, because a hard drawdown limit is breached once, not on average.
Step 3: Turn the tail into a breach probability
Pick the drawdown level that would actually stop you: a personal pain threshold, a capital-preservation rule, or an account's maximum loss limit. Count the share of paths that cross it. That single number is often more useful than any percentile.
A worked example: System A-14
Illustrative teaching example. The figures below come from "System A-14", an anonymized, composite daily-bar trend system built for our sample stress-test report. It is not a live system or a client result. The test used 2,000 runs of trade-sequence reshuffling plus a separate resampling-with-replacement run.
| Metric | Original backtest | MC 5th pct. | MC median | MC 95th pct. |
|---|---|---|---|---|
| Maximum drawdown | 18.6% | 14.1% | 21.3% | 33.8% |
| Net return (full period) | Baseline | −0.6x baseline | 0.9x baseline | 1.6x baseline |
| Probability of exceeding 25% drawdown at some point | — | — | 29% | — |
Illustrative example only. Historical simulation, not predictive of future or live results.
Read in the order above:
- Median vs backtest. The median simulated drawdown of 21.3% is reasonably close to the backtest's 18.6%. The original curve was not a wildly lucky ordering. That is the main thing this test screens for, and it was a conditional pass.
- The tail. The 95th-percentile path reaches 33.8%, nearly double the headline figure. Anyone sizing risk off 18.6% alone would be underestimating plausible worst-case exposure by a wide margin.
- Breach probability. In 29% of simulated paths, drawdown exceeded 25% at some point. Roughly three paths in ten crossed a level well beyond the backtest's own maximum.
- The return range. The 5th-percentile path ended at −0.6x the baseline return, meaning some resampled paths lost money over the full period even though the backtest made money.
None of this says the strategy is good or bad. It says the single backtest figure was a poor guide to sizing. In the full report, the walk-forward test then found decay that Monte Carlo could not see at all, which is why no single test is enough. The walk-forward side is covered in how to walk-forward test an EA.
What to do with the result
Monte Carlo output is most useful as a sizing input.
- Decide your stop level first. Write down the drawdown at which you would stop trading the strategy, before you look at the simulation.
- Compare it with the tail. If the 95th-percentile drawdown is beyond your stop level, the current sizing has a meaningful chance of ending the strategy on sequence alone.
- Scale risk, then re-run. For small per-trade risk, percentage drawdowns scale roughly in proportion to risk per trade, so reducing risk per trade shrinks the whole distribution. The relationship is not exactly linear because of compounding, so re-run the simulation at the new size rather than dividing by hand.
- Record the breach probability you accepted. A written number makes the decision explicit and stops you quietly moving the goalposts later.
The limits of Monte Carlo testing
Monte Carlo is a strong tool with clear blind spots. Know them before you trust the output.
- It assumes trades are independent. Reshuffling destroys any real clustering. If losses genuinely cluster, for example in a trend system during long ranges, simple reshuffling can understate how long drawdowns last. A block bootstrap, which resamples runs of consecutive trades rather than single trades, keeps some of that structure.
- It can only use trades that happened. A regime absent from the backtest is absent from every simulated path too.
- It inherits every bias in the input. Overfit parameters, look-ahead errors, unrealistic fills and missing costs all pass straight through. If your backtest fills are optimistic, see why an EA trades worse live than in its backtest. Run Monte Carlo on out-of-sample trades where you can, not only on the in-sample backtest the parameters were tuned on.
- Small samples give false precision. Two thousand simulations of thirty trades is still thirty trades of information.
- It cannot see inside a trade. Trade-level simulation ignores floating drawdown. Rules measured on equity need equity-level testing.
Common Monte Carlo mistakes
- Reporting the median as "the" drawdown. Half of all paths are worse than the median by definition.
- Expecting reshuffling to change the return. With the same trades, the end point is the same. If your tool shows different final returns from a pure reshuffle, check what it is actually doing.
- Running it on the in-sample backtest only. The trades were selected by the optimizer. Reshuffling them doesn't remove that selection.
- Ignoring the input sample size. Check how many trades feed the simulation before reading anything into its tails.
- Treating a good result as approval. A tight distribution means the result is not sequence-dependent. It says nothing about whether the edge will continue.
Monte Carlo testing checklist
- Trade list exported with realistic costs included
- Per-trade returns expressed as a fraction of equity
- Reshuffling run for sequence risk; bootstrap run for the return range
- Enough runs that the 95th percentile is stable between seeds
- Stop level written down before reading results
- Breach probability recorded for that stop level
- Simulation repeated on out-of-sample trades where available
- Equity-level drawdown checked separately if account rules use equity
Frequently asked questions
What is a Monte Carlo test for a trading strategy?
It is a simulation that rebuilds many alternative equity curves from a strategy's own trades, by reordering or resampling them, to show how widely drawdowns and returns could vary if the same kind of trades arrived differently.
How many Monte Carlo simulations do I need?
There is no fixed number. A few thousand is a common starting point. The practical test is stability: if the percentile you care about changes noticeably when you re-run with a different seed, you need more runs.
Should I reshuffle trades or resample with replacement?
They answer different questions. Reshuffling isolates sequence risk and leaves the final return unchanged. Resampling with replacement varies the mix of trades, so it shows a range of returns as well as drawdowns. Running both gives a fuller picture.
Does a good Monte Carlo result mean my EA is robust?
Not on its own. It means the backtest results are not overly dependent on trade order. It cannot detect overfitting, data errors or regime change, which is why it is paired with out-of-sample and walk-forward testing.
Can Monte Carlo tell me the chance of breaching a drawdown limit?
It can estimate it for the simulated paths, given the trades you supply. That estimate is only as good as the input and the independence assumption, and it does not predict future market conditions.
Want a second pair of eyes?
Start with our free Sample Stress-Test Report. It walks one anonymized, illustrative strategy through a full stress test, start to finish, so you can see what rigorous validation looks like before you test your own.
Read the Sample Stress-Test ReportWant your own backtest checked? The Strategy Audit + 60-minute call is a paid service at a launch price of £100, credited in full against our build and portfolio offers. You send an MT4/MT5 Strategy Tester report or trade-list CSV; what we can check depends on the files you supply, and walk-forward and parameter sweeps are not included because they need the strategy itself. It is analysis of strategy testing, not investment advice, and does not promise any trading or evaluation outcome. See the Strategy Audit
Disclaimers
CollosoTrading provides educational content and analytical services for retail and professional algorithmic traders. We do not provide regulated investment advice, financial advice, or personal recommendations. Trading derivatives, leveraged products, and CFDs carries a high level of risk and may result in losses exceeding deposits. Past performance, including any verified or unverified historical results referenced on this site, is not indicative of future results. Consult an independent regulated financial adviser before making investment decisions.
All figures are backtests or simulations unless marked LIVE. Hypothetical or backtested performance results have inherent limitations and may not reflect actual trading. No representation is made that any account will or is likely to achieve profits or losses similar to those shown. Individual results vary. All figures in this article come from an anonymized, illustrative teaching example. We do not guarantee the outcome of any prop firm challenge.