Monte Carlo Simulation for Trading Bots: Reading Probability of Ruin
Your backtest hands you one equity curve. It rises, it dips, it ends at some final number, and it feels like the truth about your strategy. It is not. It is one ordering of your trades out of an astronomical number of possible orderings, and the order you happened to get can flatter a fragile strategy or bury a solid one.
Monte Carlo simulation is how you see past that single lucky (or unlucky) sequence. Freya's backtest engine reshuffles your trades a thousand times and reports the full range of outcomes, including the one number a single backtest can never show you honestly: the probability that this strategy wipes out your account.
Key Takeaways
- A single backtest is one ordering of your trades; the same trades in a different order can end in profit or ruin.
- Monte Carlo resamples your trades 1000 times to map the distribution of outcomes, not just the one that happened.
- Probability of ruin is the share of those reorderings where the account is effectively wiped out; even a few percent is a red flag.
- The 95th-percentile drawdown, not your single backtest's drawdown, is the pain you should actually plan for.
- Freya needs at least 10 trades to run the simulation, and the result is deterministic, so the same backtest always gives the same numbers.
- Monte Carlo stress-tests sequence risk. It cannot model a market regime change, so pair it with walk-forward validation.
If you have not run a backtest yet, start with the step-by-step backtesting guide, and read interpreting backtest results for the core metrics this article builds on.
The dollar amounts and percentages here are worked examples, not recommendations. Crypto trading can lose money. Size every bot with funds you can afford to lose, and read the full Risk Disclosure before going live.
Why One Equity Curve Lies
Imagine a strategy with 40 trades: 24 winners and 16 losers. Your backtest played them in the exact order the market delivered them. But that order was luck. If the three worst losses had landed back to back near the start, before your account had a profit cushion, the same 40 trades could have drawn the account down far enough to trigger liquidation or a stop-out you never recovered from. Play them in a kinder order and the account glides to a new high.
Same trades. Same win rate. Same average win and average loss. Completely different survival outcome. This is sequence risk, and it is invisible in a single equity curve because a single curve only shows you one sequence.
Monte Carlo simulation exists to make sequence risk visible.
What Monte Carlo Actually Does on Freya
Freya's engine takes the list of trades your backtest produced and runs a bootstrap resampling: it draws your trades at random, with replacement, into a fresh order, then walks an equity curve through that order and records where it ended and how deep it fell along the way. It repeats this 1000 times, building a distribution of a thousand plausible alternate histories your strategy could have lived through.
A few details worth knowing, because they are what make the numbers trustworthy:
- It needs at least 10 trades. Below that, there is not enough of a sample to reshuffle into anything meaningful, so Freya returns no Monte Carlo result rather than a misleading one. In practice you want many more than 10 for the distribution to mean much.
- It is deterministic. The simulation is seeded from your backtest's own results, so running the same backtest gives you the same Monte Carlo numbers every time. The randomness is in the reshuffling, not in the report.
- A run stops at ruin. Once a simulated account falls to the ruin level, that run ends there, exactly as the live engine halts a depleted account. The simulation does not keep stacking imaginary trades onto an account that no longer has capital, so drawdowns stay bounded by what there actually was to lose.
How Freya resamples depends on how your bot sizes positions. With fixed sizing, every trade risks a similar absolute amount, so the engine reshuffles the raw profit and loss of each trade. With compounding, a trade's dollar result depends on how big the account was when it happened, so the engine reshuffles the percentage returns instead. Reshuffling raw dollars for a compounding bot would invent outcomes the strategy could never produce, so Freya deliberately matches the resampling to your sizing method.
Reading the Monte Carlo Output
After a backtest with enough trades, the Monte Carlo panel reports the distribution across all 1000 runs. Here is what each number is telling you and how to act on it.
Probability of ruin
The single most important number. It is the percentage of the 1000 reorderings in which the account was effectively wiped out, meaning it fell to roughly a tenth of the balance you started with. A strategy that never once ruined across a thousand reshuffles is showing structural resilience. A strategy with even a 2 to 5 percent probability of ruin is telling you that one unlucky ordering of the very same trades ends your account, and live markets are perfectly capable of dealing you that order.
Treat any non-zero probability of ruin as a sizing problem to solve before you go live, not a rounding error to ignore.
Probability of profit
The mirror image: the percentage of reorderings that finished in the green. A strategy can have a beautiful single backtest and still end positive in only, say, 60 percent of reorderings, which means four times out of ten a different sequence would have handed you a loss. The closer this is to 100 percent, the less your result depended on getting a friendly order of trades.
Confidence intervals
The 95 percent and 99 percent confidence intervals give you the range your final equity landed in across the simulations. The single number your backtest ended on is one point inside this range, and often not the middle one. If your backtest ended at the top of the 95 percent interval, your headline result was near the optimistic edge of what this strategy plausibly does. The interval, not the single figure, is the honest expectation.
Median, best case, and worst case
The median final equity is the middle outcome, a more robust expectation than the single backtest number because half the reorderings did better and half did worse. Best case and worst case are the extreme tails: the luckiest and unluckiest sequences the simulation drew. The gap between them is a quick read on how much your outcome rides on luck.
Median and 95th-percentile drawdown
This pair is where Monte Carlo earns its keep. Your single backtest reported one maximum drawdown. Monte Carlo reports the median drawdown across all reorderings and the 95th-percentile drawdown, the near worst case. If your backtest's drawdown was 18 percent but the 95th-percentile Monte Carlo drawdown is 34 percent, your backtest got a gentle ordering, and 34 percent is closer to the pain you should actually be sized and prepared for. Plan for the 95th percentile, not the single run.
| Monte Carlo signal | What it means | What to do |
|---|---|---|
| Probability of ruin above 0% | One unlucky order of your trades wipes the account | Cut position size or leverage until ruin reaches 0% |
| Probability of profit below ~70% | Your positive result leaned on a friendly trade order | Widen the edge or tighten risk before trusting it |
| 95th-pct drawdown far above backtest drawdown | Your single backtest got a lucky sequence | Size for the 95th-percentile drawdown, not the backtest one |
| Wide gap between best and worst case | Outcome is highly luck-dependent | Treat the median, not the headline, as the expectation |
A Worked Example
Say two strategies both backtest to a tidy +22 percent on $10,000, ending near $12,200. On the single equity curve they look like twins. Monte Carlo tells them apart:
- Strategy A: probability of ruin 0 percent, probability of profit 91 percent, median final equity $11,900, 95th-percentile drawdown 16 percent. Almost every reordering survives and profits. This is a robust edge.
- Strategy B: probability of ruin 7 percent, probability of profit 63 percent, median final equity $10,400, 95th-percentile drawdown 41 percent. The same headline number, but it was carried by a handful of large wins that happened to land after the account had a cushion. Reorder those wins earlier or later and a meaningful slice of runs draw down catastrophically.
The single backtest could not separate these. Monte Carlo makes the difference impossible to miss, and it is exactly the difference between a bot you can size confidently and one that will eventually hand you its worst case.
What Monte Carlo Cannot Tell You
Monte Carlo is a stress test of one specific risk: the order your trades arrive in. It is not a crystal ball, and treating it as one is its own trap.
- It assumes your trades are representative. Reshuffling the trades you have cannot conjure a trade the strategy never made. If a market regime shifts and your edge stops working, Monte Carlo built from the old trades will keep reshuffling the old, now irrelevant, results. For that failure mode you need walk-forward analysis, which tests your parameters on data they were never fitted to.
- Garbage in, garbage out. If the underlying backtest is overfitted, Monte Carlo just reshuffles fantasy trades into a thousand fantasy histories. Confirm the backtest is honest first, using the overfitting checks in interpreting backtest results.
- It reshuffles, it does not forecast. Live results also differ from any backtest because of latency, partial fills, funding, and Freya's performance fee, none of which a reordering models. See backtest vs live results for that gap.
Used together, these three tools cover the three big ways a good-looking backtest fails: Monte Carlo for sequence risk, walk-forward for overfitting, and the live-versus-backtest guide for execution reality.
Frequently Asked Questions
What is probability of ruin in a backtest?
It is the percentage of simulated reorderings of your trades in which the account was effectively wiped out, falling to roughly a tenth of your starting balance. Freya computes it by resampling your backtest's trades 1000 times. Any value above zero means at least one plausible order of your own trades ends your account, which is a signal to reduce size or leverage.
How many trades do I need for Monte Carlo to work?
Freya requires at least 10 trades before it will run the simulation, and returns no Monte Carlo result below that. Ten is the floor, not the target. The more trades you have, the more the distribution and the probability of ruin can be trusted.
Why is the Monte Carlo drawdown worse than my backtest drawdown?
Because your single backtest saw only one ordering of trades, and it was often a relatively kind one. Monte Carlo reveals the drawdown across a thousand orderings, and the 95th-percentile figure is the near worst case. If it is much deeper than your backtest drawdown, your headline result got a lucky sequence, and you should size for the 95th-percentile number.
Will the same backtest give the same Monte Carlo result twice?
Yes. Freya's simulation is seeded from your backtest's own results, so it is deterministic. Running the identical backtest produces the identical Monte Carlo numbers. The reshuffling is random, but it is reproducible.
Does a 0 percent probability of ruin mean the strategy is safe?
No. It means that across a thousand reorderings of your backtested trades, none wiped out, which is a strong resilience signal for sequence risk only. It says nothing about a market regime change or an overfitted backtest. Combine it with walk-forward validation and a sanity check on the backtest itself before going live.
