Monte Carlo Simulation
Monte Carlo simulation uses randomness to explore the range of possible outcomes for a trading strategy. Instead of looking at a single backtest equity curve and saying “this is what would have happened,” Monte Carlo asks: “what could have happened if trades occurred in a different order, or if conditions varied slightly?”
The core idea: take your backtest results (the list of individual trade returns) and randomly shuffle, resample, or perturb them thousands of times. Each shuffle produces a different equity curve. Analyze the distribution of all those curves to understand the realistic range of outcomes.
A single backtest gives you one path. Monte Carlo gives you thousands — and shows you the probability distribution of drawdown, final return, and worst losing streaks.
Why Monte Carlo Matters
A backtest produces one equity curve based on one specific historical sequence. But that sequence is just one realization of many possible outcomes.
- Drawdown estimation: Your backtest might show 15% max drawdown. But Monte Carlo might reveal a 10% chance of 30% drawdown with different trade ordering. Critical for position sizing.
- Luck vs. skill: If great performance depends on a specific sequence of winning trades, Monte Carlo exposes this fragility.
- Confidence intervals: Instead of “the strategy returned 20%,” you can say “95% probability the strategy returns between 8% and 32%.”
- Ruin probability: Estimate the chance of hitting a catastrophic drawdown (e.g., losing 50%) — something a single backtest can’t do.
- Stress testing: Add random noise to fills, slippage, or skip random trades to test sensitivity to real-world imperfections.
Concrete Examples
Trade Resampling
Your strategy produced 200 trades over 3 years with 45% net return. Run 10,000 Monte Carlo simulations by resampling (with replacement) 200 trades each time.
Results:
- Median return: 42%
- 5th percentile: 12%
- 95th percentile: 78%
- Median max drawdown: 18%
- 95th percentile max drawdown: 34%
Insight: while expected return is ~42%, you should prepare for drawdowns up to 34% and returns as low as 12% in unlucky scenarios. Size positions based on the worst case, not the median.
Trade Shuffling
Your equity curve shows a smooth uptrend because big winners happened after small losers. Shuffle the trade order 5,000 times. In many shuffles, big winners cluster at the end (making the middle look like a deep drawdown) or losers cluster together (creating a scary losing streak).
Your single backtest made the strategy look smoother than it really is. Monte Carlo shows you the full range of possible equity curve shapes.
Strategy Comparison
Strategy A: 25% return, Monte Carlo 5th percentile = 5% Strategy B: 20% return, Monte Carlo 5th percentile = 12%
Strategy A looks better in the backtest, but Strategy B has much better worst-case scenarios. Monte Carlo helps you pick the more robust strategy, not just the one with the highest point estimate.
Skipped Trades
Real execution isn’t perfect. You might miss signals from connectivity issues or skip trades while sleeping. Monte Carlo can randomly remove 5-10% of trades and show the impact.
If removing a few trades destroys profitability, your strategy depends on catching every single signal — a risky proposition for any real-world deployment.
How to Run Monte Carlo Analysis
1. Collect Trade Results
Extract the list of individual trade P&L values from your backtest.
2. Choose Your Method
- Trade shuffling: Randomly reorder trades. Tests sequence dependency.
- Resampling with replacement (bootstrap): Draw N trades randomly from your list (same trade can repeat). Tests statistical reliability.
- Parameter perturbation: Add small random noise to strategy parameters. Tests parameter sensitivity. Related to optimization robustness.
- Data perturbation: Add noise to price data or slippage estimates. Tests data sensitivity.
3. Run Thousands of Iterations
5,000-10,000 simulations is standard. More is better but has diminishing returns.
4. Analyze the Distribution
- Plot the distribution of final returns
- Plot the distribution of maximum drawdowns
- Calculate percentiles (5th / 25th / 50th / 75th / 95th)
- Calculate probability of ruin (drawdown exceeding your maximum tolerance)
5. Size Based on Worst Cases
Set position sizes and risk limits based on the 95th percentile drawdown, not the median. If the 95th percentile drawdown exceeds your tolerance, reduce position sizes until it doesn’t.
Practical Tips
- Don’t assume trade independence: If trades are correlated (e.g., multiple positions in correlated stocks), simple shuffling overstates diversification. Use block bootstrapping to preserve clustering.
- Account for regime dependency: If your strategy has distinct bull/bear performance, shuffling trades across regimes is misleading. Consider regime-aware Monte Carlo.
- Combine with walk-forward analysis: Run Monte Carlo on walk-forward out-of-sample results for the most realistic assessment.
- Use it for position sizing: If Monte Carlo shows 25% chance of 30% drawdown at current size, reduce size until the 30% drawdown probability drops below 5%.
Tools
- AmiBroker, QuantConnect, MultiCharts: Built-in Monte Carlo support
- Python:
numpy.randomfor custom simulations — straightforward to implement - R: The
bootpackage provides robust bootstrapping - Dedicated: Equity Monaco, Market System Analyzer
A basic Python implementation is ~30 lines of code: generate random trade sequences, calculate equity curves, collect statistics.
Resources
- Investopedia: Monte Carlo Simulation — general overview with financial applications
- Trading Strategy AI: Monte Carlo for Backtesting — why it matters
- Quantified Strategies: Monte Carlo in Trading — practical application
- AmiBroker: Monte Carlo Guide — platform documentation
- The Mathematics of Money Management by Ralph Vince — deep dive on Monte Carlo for position sizing
- Kevin Davey, Building Winning Algorithmic Trading Systems — Monte Carlo validation chapter
- Systematic Trading by Rob Carver — Monte Carlo in portfolio risk management