A monte carlo simulation in trading asks a simple, slightly uncomfortable question: if your backtested trades had arrived in a different order, how bad could things have looked? Your backtest gives you one equity curve. The market will hand you a different one. Monte Carlo lets you see hundreds or thousands of those alternative curves before you put real rupees on the line.
We like it for one reason above all. It replaces a single, flattering number (the backtest’s maximum drawdown) with a range, and ranges are what you actually live through as a trader. In this piece we’ll cover what the method is, the two ways traders usually apply it, a full worked example we ran on a hypothetical set of 50 trades, and the traps that make the output look more scientific than it is.
In this article
What a monte carlo simulation actually does
Investopedia describes it as a way to model the probability of different outcomes in a process that can’t easily be predicted because random variables get in the way. Instead of plugging a single average into a model, it feeds in many values for the uncertain input, runs the model each time, and looks at the spread of results.
The Wikipedia entry on the Monte Carlo method boils the general recipe down to four moves: define the range of possible inputs, generate inputs randomly from a probability distribution over that range, run a fixed calculation on each set of inputs, and aggregate the results. The name comes from the Monte Carlo Casino in Monaco. Stanisław Ulam, the mathematician who developed the modern method while working on nuclear weapons projects at Los Alamos in the 1940s, was inspired by his uncle’s gambling there.
For a trader, the “uncertain input” is usually one of two things: the order in which trades arrive, or which trades show up at all.
Two ways to run a monte carlo simulation in trading
1. Reshuffling the trade order
Take every trade from your backtest, keep the exact same results, and shuffle the sequence. Do that thousands of times. The final profit never changes, because you’re adding up the same numbers. What changes is the path: the losing streaks, the depth of the worst dip, the time spent underwater.
This is the cleanest test of drawdown risk. Your backtest might have had its losers neatly spread out. Real life might bunch eight of them together in a month when Nifty chops sideways.
2. Resampling with replacement
The second approach, often called bootstrapping, builds each simulated run by drawing trades at random from your list, putting each one back after it’s drawn. So a single run might contain your best trade three times and your worst trade twice, and skip some trades entirely. Now the final profit varies too. This answers a different question: given trades that look like mine, how often does a 50-trade stretch end in the red?
Most serious testing uses both. Shuffling tells you about the pain along the way. Resampling tells you about the uncertainty in the end result.
A backtest shows you the one path that happened. Monte Carlo shows you the hundreds of paths that could just as easily have happened instead.
A worked example: 50 hypothetical trades
Everything in this section is hypothetical. We made up a trade list to show the mechanics and ran the simulation ourselves with a short Python script. None of it is real market data or a real strategy’s record.
Say a swing trader has backtested a breakout system on NSE stocks and logged 50 trades, measured in R-multiples (1R being the amount risked per trade):
- 19 winners, each +2.5R
- 31 losers, each −1R
- Win rate: 19 out of 50, or 38%
- Net result: (19 × 2.5) − 31 = 47.5 − 31 = +16.5R
- Expectancy: 16.5R ÷ 50 trades = +0.33R per trade
That’s a positive trading expectancy, and the backtest’s own equity curve looks lovely. In the original order, the worst peak-to-trough drawdown was just 3R and the longest losing streak was 3 trades. On a ₹5,00,000 account risking 1% per trade (₹5,000 per R, kept fixed for simplicity), that’s a worst dip of ₹15,000, or 3% of the account. Very easy to sit through.
Step 1: shuffle the order 10,000 times
We kept all 50 results and reshuffled them 10,000 times, measuring the maximum drawdown and the longest losing streak in each run. Here is what came back.
| Measure (10,000 shuffles) | Max drawdown | In rupees at ₹5,000 per R | Longest losing streak |
|---|---|---|---|
| Original backtest order | 3R | ₹15,000 | 3 trades |
| Median run | 7R | ₹35,000 | 6 trades |
| 90th percentile | 10.5R | ₹52,500 | not measured |
| 95th percentile | 11.5R | ₹57,500 | 10 trades |
| 99th percentile | 14R | ₹70,000 | not measured |
| Worst single run | 19R | ₹95,000 | 17 trades |
Look at the gap. The backtest said 3R. The typical shuffled run said 7R, more than double. In one run in twenty, the drawdown reached 11.5R or more, which is 11.5% of the starting capital at our fixed ₹5,000 risk. About 15% of all runs (1,479 of 10,000) saw a drawdown of 10R or deeper. And not a single shuffled run had a drawdown smaller than the original 3R.
Put plainly, this backtest happened to draw a very lucky sequence. Its headline drawdown was close to the best case, not a fair guess at what to expect.
Step 2: resample with replacement 10,000 times
Next we built 10,000 runs of 50 trades each by drawing at random from the same list with replacement. Now the end result moves around.
- Median final result: +16.5R, matching the backtest.
- 5th percentile (a bad run): −4.5R, so a loss of ₹22,500 after 50 trades.
- 95th percentile (a good run): +37.5R.
- Runs finishing flat or negative: 9.58%, roughly one in ten.
- 95th percentile drawdown: 14.5R, deeper than the shuffle test, because some runs drew fewer winners.
So even with a genuine positive edge of +0.33R per trade, about one 50-trade stretch in ten ended with nothing to show for it. That’s not a flaw in the system. It’s what a 38% win rate does over a small sample.
Step 3: turn the numbers into decisions
This is where the exercise pays for itself. Three practical calls come straight out of the table.
- Size for the 95th percentile, not the backtest. If an 11.5% drawdown at 1% risk per trade would make you abandon the system, cut risk. At 0.5% per trade, the same 11.5R drawdown is about 5.75% of capital.
- Expect streaks of 6 to 10 losers. A median longest streak of 6 and a 95th percentile of 10 means a run of seven straight losses is normal for this system. Write that down before you start trading it, so you don’t “fix” a working strategy in the middle of an ordinary bad patch.
- Set a kill switch with some evidence behind it. If live drawdown blows well past the 99th percentile (14R here), something has probably changed in the market or in your execution. That’s a far better trigger for a review than gut feel.
Our post on risk of ruin goes into how per-trade risk and win rate combine to threaten an account outright, and Monte Carlo is a practical way to put numbers on that for your own trades.
If you size your positions off the backtest’s best-case drawdown, the first ordinary losing streak will feel like the system is broken.
Where monte carlo simulation misleads traders
The output looks precise, with neat percentiles and clean tables. Treat it with some suspicion anyway.
Garbage in, garbage out. Shuffling and resampling only rearrange the trades you gave it. If your backtest is curve-fitted, ignores brokerage, STT and slippage, or was tested on a cherry-picked set of stocks, the simulation will faithfully reproduce those flaws thousands of times.
It assumes trades are independent. Shuffling treats every trade as if it could have happened at any point. In reality, losses tend to cluster. A trend-following system bleeds together during range-bound months, and gap-downs on results days or global sell-offs can hit several open positions at once. Plain shuffling breaks that clustering apart, so it can understate how bad bunched losses get.
History isn’t the whole distribution. Investopedia points out that the method relies on historical data and statistical assumptions about market behaviour, and that there’s no guarantee actual movements won’t exceed the wildest projections. It also notes that a price-based Monte Carlo ignores anything not built into the price data, such as macro trends, company leadership, market hype and cyclical factors. If your 50 trades all came from one bull phase, no amount of reshuffling will show you what a bear market does to the system.
Small samples are shaky. Fifty trades is a thin base. The Wikipedia article notes that the error in Monte Carlo estimates typically shrinks with the square root of the number of samples, so quadrupling the samples halves the error. Running 100,000 simulations instead of 10,000 smooths the percentiles, but it can’t add information your original 50 trades didn’t contain. More real trades help far more than more simulated ones.
How to run one yourself
You don’t need special software. A spreadsheet or a few lines of Python will do it.
- Export your backtest or live trade log and convert each trade to an R-multiple (profit or loss divided by the initial risk), after costs.
- For the shuffle test, randomly reorder the list, rebuild the equity curve, and record the maximum drawdown and longest losing streak. Repeat a few thousand times.
- For the resampling test, build each run by drawing trades at random with replacement, the same number as your sample, and record the final result and drawdown.
- Sort the outcomes and read off the median, 90th, 95th and 99th percentiles.
- Convert R into rupees at your planned risk per trade and ask honestly whether you could keep trading through the 95th percentile drawdown.
If you want to go further, some traders shuffle trades in blocks (say five or ten in a row) to keep some of the clustering intact. It’s a sensible refinement once the basic version makes sense to you.
Where it fits in your risk plan
Monte Carlo won’t tell you whether a strategy works. Your expectancy, sample size and cost assumptions do that. What it does well is calibrate your expectations and your position size, so the drawdown you plan for is a realistic one rather than the lucky one your backtest happened to show. Pair it with the basics in our risk management in trading guide and you’ll have a much clearer idea of what “normal” bad looks like before it arrives.
Disclaimer: This article is for educational purposes only and is not investment advice. The trade list and simulation results are hypothetical and do not represent any real strategy or market data. Trading involves risk, including loss of capital. Please do your own research or consult a SEBI-registered investment adviser before making any investment decision.

Leave a Reply
Join the conversation
Commenting is open to registered readers. Sign up with just your email — no password needed, and it takes under a minute.
Sign up to comment Log in