Monte Carlo robustness
Your backtest produced one equity curve, but that curve is a single draw from a distribution of things that could have happened. Monte Carlo methods resample your trades to reveal that distribution, so you size positions for the drawdown you might actually face, not the one lucky path you happened to see.
One equity curve is one sample
The exact order your trades happened in is partly luck. Had three losers clustered early instead of being spread out, your worst drawdown would have been deeper and your account might not have survived it. The single backtest curve hides this: it shows one ordering out of millions. Monte Carlo robustness testing asks what the other orderings look like, so you can plan for a bad one.
Reshuffling and resampling trades
The simplest Monte Carlo takes your actual list of trade results and reshuffles their order many times, recomputing the equity curve and the maximum drawdown each time. A richer version resamples trades with replacement (bootstrapping), which also varies which trades appear and how often. Either way you get a distribution of outcomes instead of a point estimate, and the spread of that distribution is the honest measure of how lucky or unlucky your single backtest was.
Monte Carlo on the trade sequence (Python)
PythonShuffle the realized trade returns many times and record the worst drawdown of each ordering. The distribution shows the risk one curve hides.
import random
def max_drawdown(equity):
peak, mdd = equity[0], 0.0
for v in equity:
peak = max(peak, v)
mdd = max(mdd, (peak - v) / peak)
return mdd
def monte_carlo_drawdowns(trade_returns, runs=5000, start=10000.0):
worst = []
for _ in range(runs):
order = random.sample(trade_returns, len(trade_returns))
equity, bal = [start], start
for r in order:
bal *= (1 + r)
equity.append(bal)
worst.append(max_drawdown(equity))
worst.sort()
return worst[int(0.95 * runs)] # 95th-percentile drawdown Reading the outcome distribution
Do not look at the average; look at the tail. The median final equity is reassuring but useless for survival. What matters is the 95th-percentile drawdown: the bad-but-plausible loss you should assume you will eventually hit. If that number would blow up your account or your nerve, the strategy is too risky at your position size even though the single backtest looked fine. Size so that the tail is survivable, not so that the median is exciting. Read drawdown for why it is the metric that ends accounts.
Tip
Export your trades
TradingTune lets you export a run, so you can pull the realized trade list into a notebook and run resampling on the actual results rather than a toy model.
Combine with walk-forward
Monte Carlo and walk-forward analysis answer different questions. Walk-forward asks whether the edge survives unseen time; Monte Carlo asks how rough the ride could be even if it does. A strategy worth trading should pass both: a real out-of-sample edge and a tail drawdown you can live with. Neither alone is enough, and together they are far harder to fool than any single backtest number.
Key idea
The one rule
Size your position for the 95th-percentile drawdown from resampling, not for the one drawdown your single backtest happened to show.
Key takeaways
- A backtest curve is one ordering out of millions of possible ones.
- Reshuffle or resample trades to get a distribution of outcomes.
- Plan for the tail (95th-percentile) drawdown, not the median.
- Pair Monte Carlo with walk-forward: edge survival plus survivable risk.
Frequently asked questions
What is Monte Carlo robustness testing for trading?
Resampling or reshuffling a strategy's realized trades many times to build a distribution of possible equity curves and drawdowns, revealing how much the single backtest result depended on the lucky order trades happened to occur in.
Why look at the worst-case drawdown instead of the average?
The average says nothing about survival. The tail (for example the 95th-percentile drawdown) is the bad-but-plausible loss you should assume you will eventually hit, and you must size your position so that loss is survivable.
Does Monte Carlo replace walk-forward analysis?
No. Walk-forward tests whether the edge survives unseen time; Monte Carlo tests how rough the ride could be even when it does. A strategy worth trading should pass both.
Related guides
- Advanced
Walk-forward analysis
Validate a TradingView strategy with walk-forward analysis: roll optimize-then-test windows forward to prove an edge survives out of sample, repeatedly.
Read the guide - Advanced
Parameter sensitivity analysis
Find robust TradingView strategy settings with parameter sensitivity: prefer a broad performance plateau over a fragile spike, and read the neighborhood.
Read the guide - Beginner
Reading backtest metrics
How to read the backtest metrics TradingTune surfaces (net profit, win rate, profit factor, Sharpe, drawdown, trade count) and weigh them together, not one alone.
Read the guide
Put it into practice
Install TradingTune and optimize any TradingView strategy right in your browser. Free tier, no API keys. A free account is required to run.
Add to Chrome, it's free