Monte Carlo Simulation in Trading Optimization
Monte Carlo methods turn one backtest into thousands of plausible outcomes: trade reshuffling, resampling, skipped trades and cost shocks. How to run them and read drawdown and ruin probabilities.
A backtest produces one sequence of trades - one path through history. If the same trades had come in a different order, the equity curve, the maximum drawdown and the longest losing streak would all have been different. Monte Carlo simulation builds thousands of such alternative paths from the strategy’s own results, so that you can see the range of outcomes rather than a single number.
It is one of the most practical tools for answering a question every trader should ask before going live: how bad could it realistically get?
Method 1: reshuffling trades
Take the list of trade results from the backtest (in money or in R) and randomly reorder them. Rebuild the equity curve. Repeat several thousand times.
The final profit stays the same in every run - the same trades are just reordered - but the path changes. From the simulated paths you get distributions of:
- maximum drawdown;
- longest losing streak;
- time spent below the previous peak.
Example. A backtest of 300 trades shows a maximum drawdown of 11%. After 5,000 reshuffles, the median drawdown is 12%, the 95th percentile is 19% and the worst simulated path reaches 27%. The honest planning number is around 19%, not 11%.
Method 2: resampling with replacement (bootstrap)
Draw trades randomly from the list with replacement, building new sequences of the same length. Some trades appear twice, some not at all. Unlike reshuffling, this changes the final profit as well, giving a distribution of returns. It shows how dependent the result is on a few big winners: if many resampled paths end flat or negative, the edge rests on a handful of trades.
Method 3: skipping trades
Randomly remove a share of trades - for example 10% - in each simulation. This reflects real-life events: the platform was offline, a signal was missed, the broker rejected an order. Strategies that rely on catching a few rare big winners suffer most.
Method 4: perturbing costs and prices
Add random slippage to each trade, widen the spread, or shift entries slightly. This tests how much of the edge survives worse execution. If a modest random cost increase turns many runs negative, the strategy has no margin of safety.
Reading the results
Present results as percentiles, not averages:
| Measure | 5th pct | Median | 95th pct |
|---|---|---|---|
| Final return (bootstrap) | +8% | +31% | +56% |
| Maximum drawdown (reshuffle) | 7% | 12% | 19% |
| Longest losing streak | 6 | 8 | 12 |
Then use them:
- Position sizing. If the 95th-percentile drawdown at 1% risk per trade is 19% and you can tolerate 15%, reduce risk to about 0.75%.
- Stop rules. Define in advance that the strategy is reviewed if live drawdown exceeds the 95th or 99th percentile. Below that, a drawdown is normal behaviour, not a reason to panic.
- Expectations. Seeing a 12-trade losing streak in the distribution before it happens makes it much easier to keep following the rules when it does.
Risk of ruin
Define “ruin” for your situation - for example a 30% drawdown, or breaching a prop-firm limit - and count the share of simulated paths that hit it. If 4% of paths breach a 10% daily or total limit, there is roughly a 1 in 25 chance of losing the account under those rules, even if the strategy has a genuine edge.
Monte Carlo in optimisation
Monte Carlo is most useful after optimisation, to compare finalists:
- Candidate A: higher median return, 95th-percentile drawdown 28%.
- Candidate B: slightly lower median return, 95th-percentile drawdown 14%.
For most traders B is the better strategy: it can be sized up to match A’s return while keeping lower tail risk.
Limitations
- It assumes trades are independent. Many strategies have clustered results - losing streaks during choppy regimes. Reshuffling breaks those clusters and can underestimate real streaks. Block resampling (moving groups of consecutive trades together) helps.
- It cannot invent new market behaviour. Simulations reuse the trades you already have.
- Garbage in, garbage out. Monte Carlo on an overfitted backtest produces confident ranges around a fiction.
How to run it
Export the trade list from your platform - cTrader’s backtest History tab lists every deal - and run the simulation in a spreadsheet or a short script. Reshuffling 5,000 times a list of a few hundred numbers is fast on any computer.
Key takeaways
- One backtest is one path; Monte Carlo shows the range of plausible paths.
- Reshuffling shows drawdown risk, bootstrapping shows return uncertainty, perturbations show execution sensitivity.
- Size positions and set stop rules from high percentiles, not from the backtest’s single drawdown.
- Monte Carlo complements, but does not replace, out-of-sample and walk-forward testing.
FAQ
Does Monte Carlo make a strategy more profitable?
No. It does not change the strategy at all. It shows the range of results the same trades could have produced in a different order or with small changes, which is essential for sizing positions and setting drawdown limits.
How many simulations are enough?
A few thousand runs are usually enough for stable percentiles such as the 95th-percentile drawdown. Run the simulation twice with different random seeds; if the key numbers barely change, you have enough.
Can Monte Carlo detect overfitting?
Only partly. It works on the trades the backtest produced, so if those trades are the result of overfitting, the simulations inherit the problem. Use it together with out-of-sample and walk-forward tests.
Sources and further reading
- Bailey et al.: The Probability of Backtest Overfitting - papers.ssrn.com
- William F. Sharpe: The Sharpe Ratio (1994) - web.stanford.edu