Skip to main content
← Back to blog

Monte Carlo in trading: separating edge from luck

📅 Published
✍️ Strategy Arena
monte-carlo backtest robustness validation methodology

TL;DR — A backtest produces only one trade history: it is an anecdote, not proof. Monte Carlo simulation replays those same trades in thousands of different orders (bootstrap resampling) to generate thousands of "parallel universes" of the same edge. You then read the range of results — p5/median/p95 percentiles, probability of profit, probability of ruin — and derive a robustness score out of 100. Note: this test measures a strategy's statistical robustness; it does not predict the future, and its assumption that trades are independent can underestimate real risk.

The single-backtest problem

Imagine a strategy that made 120 trades over two years of BTC data. The backtest shows an equity curve rising from left to right. The temptation is to conclude: "it works."

The problem is that this curve is just one path among an infinity of possible paths. The exact order in which winning and losing trades followed one another is largely the product of historical chance. If the strategy's three biggest gains had occurred at the beginning rather than the end, the curve would look completely different. If a run of five consecutive losses had hit a little earlier, the account could have reached a much deeper trough — or never recovered.

A backtest is therefore an anecdote: "here is what would have happened, in this exact order, over this exact period." It is not proof that the advantage (the edge) is real and reproducible. Two dangers lurk:

  • The lucky survivor. A strategy with no real edge can, by pure chance, produce a flattering curve on a given sample. This is the classic trap: the more variants you test, the more likely you are to find one that "works" by accident (data-snooping).
  • The invisible drawdown. Even a strategy with a genuine edge can, under a slightly different order of trades, go through a losing streak long enough to ruin the account before the advantage shows up.

The relevant question is therefore not "does this curve go up?" but "in how many plausible scenarios does this strategy remain profitable, and in how many does it end up wiped out?" That is exactly what Monte Carlo seeks to measure.

Bootstrap resampling: a thousand stories from the same edge

The idea behind bootstrap Monte Carlo is simple and elegant. You keep the trades produced by the backtest — their individual P&L, their statistical "DNA" — but you reshuffle the deck: you randomly draw a new sequence of trades from the same set, then rebuild an equity curve. You repeat this draw thousands of times.

Here is how it is implemented on Strategy Arena (backend/backtesting/backtest_engine.py, method monte_carlo_simulation):

Pour chaque simulation (1000 par défaut côté serveur) :
    1. Tirer N trades AVEC REMISE parmi les N trades du backtest
       (bootstrap : un même trade peut sortir plusieurs fois, un autre jamais)
    2. Reconstruire une courbe d'équité en additionnant les P&L tirés
    3. Mesurer le capital final et le drawdown maximum de cette courbe

Each simulation thus produces an alternative equity curve: a parallel universe in which the same underlying edge expressed itself in a different order. By stacking 1,000 universes, you no longer look at a single point but a complete distribution of outcomes.

Concretely, the strategy draws indices at random (np.random.randint), sums the P&L in dollars (additive rather than compounded, to remain correct for both a DCA-type strategy and a classic strategy), floors equity at zero (an account cannot become negative), and tracks the equity peak to calculate the maximum drawdown of each path.

Drawing with replacement is the heart of the process: it is what introduces variance between simulations. Without replacement, you would merely permute the same set of trades and the additive final capital would always be identical.

The default version runs 1,000 simulations server-side. The interactive version at /playground, which runs entirely in your browser, runs 500 to stay instantaneous — enough for a stable distribution.

Reading the range: percentiles and histogram

Once the thousands of final capitals have been collected, the engine summarizes them. The actual outputs are as follows:

Output What it says
Mean / median final capital The expected "central" result
Best case / worst case The extremes observed across all draws
Standard deviation Dispersion: how much results vary
p5 / p25 / p50 / p75 / p95 percentiles The full range of final capitals
Maximum drawdown percentiles The range of the deepest troughs
Histogram (20 bins) The shape of the final-capital distribution
15 sample curves A handful of parallel universes to visualize

How should you read this?

  • The median (p50) is your central scenario — more reliable than the single backtest result, because it aggregates thousands of paths.
  • The gap between p5 and p95 is the key measure of uncertainty. A tight range (p5 close to p95) indicates a steady strategy: whatever the order of trades, you land within a narrow band. A wide-open range indicates a strategy whose result depends heavily on luck.
  • The p5 of final capital answers "in the worst 5% of scenarios, where does the account end up?" If it is below the initial capital, that means an unlucky but plausible scenario loses money.
  • Drawdown percentiles tell the opposite story: the p95 of maximum drawdown indicates the trough you need to be psychologically and financially prepared to survive.
  • The histogram gives the shape. A tight distribution entirely to the right of the initial capital = a good sign. A spread-out distribution that largely overlaps the starting-stake line = a fragile advantage.

The 15 sample curves provide visual intuition: you literally see the same edge trace 15 different paths, some rapid, others painful.

Probability of profit vs probability of ruin

Two figures capture the essence of the distribution:

  • prob_profit = percentage of simulations ending above the initial capital. It is the fraction of parallel universes in which the strategy makes money. A strategy with a prob_profit of 90% wins in 9 out of 10 scenarios; at 55%, it is barely above a coin flip.
  • prob_ruin = percentage of simulations losing 50% or more of the initial capital. It is the fraction of universes in which the account is severely cut down. A non-negligible prob_ruin is a major warning sign, even if prob_profit is high: it means there are plausible losing sequences capable of devastating the account.

These two metrics are read together. A strategy that often wins a little but sometimes loses heavily (high prob_profit, but non-zero prob_ruin) does not have the same risk profile as a steady strategy that never gets ruined. It is precisely this nuance that a single backtest completely masks.

The robustness score

To summarize everything in a single number comparable across strategies, the engine calculates a robustness score from 0 to 100. Here is the exact formula used:

robustness = (
    prob_profit * 0.4                       # 40 % : probabilité de profit
    + max(0, 100 - std_return) * 0.3        # 30 % : régularité (faible dispersion)
    + max(0, 100 - prob_ruin * 5) * 0.3     # 30 % : survie
)
# borné entre 0 et 100

where std_return is the standard deviation of final capitals expressed as a percentage of the initial capital.

Let's break down the three components:

  1. Probability of profit (weight 40%). The more the strategy wins across a large number of universes, the higher this term. It is the heart of the edge.
  2. Consistency (weight 30%). You start from 100 and subtract the dispersion (std_return). A strategy whose results are tight around the median is rewarded; an erratic strategy is penalized. If dispersion exceeds 100%, the term is capped at zero.
  3. Survival (weight 30%). You start from 100 and subtract prob_ruin × 5. The factor 5 makes this term very severe: a prob_ruin of 20% is enough to completely cancel this component. Survival is not negotiable.

A high score describes a strategy that wins often, varies little, and rarely gets ruined. A low score signals either an uncertain edge, unmanageable dispersion, or an unacceptable risk of ruin — or all three.

The score is not a "performance" grade in the sense of expected gains. It is a reliability grade: how much can you trust that the observed curve was not a lucky break.

Try it yourself

The most instructive approach is to handle it yourself. The /playground page includes an interactive, entirely browser-side Monte Carlo — no server calls, zero cost, and data from real simulation arenas.

You can:

  • Move the sliders for a strategy's parameters and rerun the backtest and then Monte Carlo on the fly;
  • Watch the percentile range (p5/p95), the robustness gauge, and the sample curves redraw instantly;
  • Compare the behavior of two settings to see which survives the reshuffle better — the displayed gauge summarizes the share of simulations that remain profitable;
  • Export your results to CSV and PDF, and even generate a Pine Script for TradingView.

To run a Monte Carlo on an existing strategy with the full interface (and the three-component robustness score described above), go to /backtest. And to see already-published results for tracked strategies, visit /live-results.

The most instructive exercise: take a strategy that "looks great" on its backtest curve, run Monte Carlo, and look at where the p5 falls. You will quickly understand why a single curve is never enough.

Once robustness is established, the next step is to understand where the edge comes from: an advantage concentrated in a single market phase remains fragile, even with a good robustness score. For that, see the companion article: detecting a market regime with price alone.

Frequently asked questions

Does Monte Carlo predict my future gains?

No. Bootstrap Monte Carlo reshuffles past trades; it measures how much the historical result depended on the order of trades, and therefore the robustness of the edge. It says nothing about future market conditions, which can differ radically from the past. It is a reliability test, not a crystal ball.

What is the difference between a good and a bad robustness score?

A high score describes a strategy that wins in the vast majority of simulated universes (high prob_profit), with tight results (low std_return) and an almost-zero risk of ruin. A low score reveals that at least one of these three conditions fails. Because the survival factor is weighted severely (prob_ruin × 5), a strategy that gets ruined in even a few percent of cases sees its score drop sharply.

Why draw trades "with replacement"?

Because that is what creates variance between simulations. If you merely permuted the same set of trades without replacement, the additive final capital would always be identical from one simulation to the next. Drawing with replacement generates genuinely different sequences — some with more winners, others with clusters of losers — and it is this diversity that reveals the distribution of possible outcomes.

How many trades are needed for this to be reliable?

The engine requires a minimum of 3 trades, but that is a technical floor, not a recommendation. With 3 or 10 trades, the bootstrap has almost nothing to reshuffle and the distribution remains poor. For serious conclusions, you ideally want several dozen or even hundreds of trades, so that resampling explores a genuine variety of sequences.

Methodology & limitations

Let's be precise about what this test does and does not do.

Data. Monte Carlo starts from the trades produced by a backtest on real market data (historical prices). Server-side, 1,000 simulations; in the interactive /playground version, 500. P&L are summed (additive, not compounded) and equity is floored at zero. Outputs: mean/median/best/worst/standard deviation of final capitals, p5..p95 percentiles of capital and maximum drawdown, a 20-bin histogram, 15 sample curves, prob_profit, prob_ruin, and robustness_score.

Central assumption — and its limitation. Bootstrap resampling assumes that trades are approximately independent and identically distributed (IID). This is a simplification. Real markets exhibit autocorrelation and volatility clustering: turbulent periods follow one another, and losing streaks are often correlated with each other. By reshuffling trades as if they were independent, the bootstrap can therefore underestimate the risk of long losing streaks and smooth out troughs that reality would produce more harshly.

What the test does NOT prove. It does not prove that the strategy will be profitable tomorrow. It does not capture a change in market regime, nor slippage, nor fees beyond what the underlying backtest incorporates. A high robustness score means "this curve was probably not pure luck," not "this strategy is guaranteed."

How to complement it. Reshuffle Monte Carlo is a first barrier, not the last. To go further:

  • walk-forward tests the strategy on successive time windows (training then out-of-sample validation), which addresses overfitting;
  • block bootstrap resamples in blocks of consecutive trades rather than trade by trade, which preserves part of the autocorrelation and specifically corrects the IID weakness described above.

Lab discipline. On Strategy Arena, a strategy is never promoted on the beauty of its curve alone: it must survive Monte Carlo — solid robustness score, controlled prob_ruin, reasonable percentile range — before going further. This is one step in the validation process detailed in /methodology and /trading-strategy-validation. For definitions of terms (Brier, Sharpe, drawdown, Monte Carlo…), see the /glossary.


Strategy Arena is an educational simulation platform (paper trading) and a research lab. Its strategies are designed by AI, executed on simulated data. Nothing above constitutes financial advice or a promise of performance. Trading carries a risk of loss; test and learn above all.

Test your own Pine strategy on a sealed period: free online judge.

⚠️ Disclaimer — This article is for informational and educational purposes only. It does not constitute investment advice or a buy/sell recommendation. Past performance does not guarantee future results. Strategy Arena is an educational simulator with virtual capital. Always do your own research before making investment decisions.

Enjoyed this article? Share it

𝕏 Share on X ✈️ Telegram

Turn a local result into durable proof

The Lab runs free on your PC. Certificates and audit dossiers use credits: 1 credit = 1 certificate or 1 dossier, 2 offered when you open an account; paying never changes the verdict.

Get the Lab (free)Audit a TradingView export Pricing and credits Publish a Lab Report Lab Reports Hall
TradingView Starter
Choose the account path. Prove the strategy separately.
Your first chart and price alert do not require the Lab. Strategy Arena proof remains required before trusting or exporting a strategy.
Partner attribution is for first-time users and web purchases only. Strategy Arena may earn a commission on eligible purchases; starting with a free account needs no payment.
I have never had an account · Start free I already have an account Check a strategy
More TradingView paths
Evidence-gated Pine review