Free trial
Menu
Learn guide

Stress Testing Algo Strategies Under Randomness

A Monte Carlo simulation tests a trading strategy against randomness. Instead of relying on the single sequence of trades in your backtest, it creates thousands of alternative sequences and shows the range of outcomes the same strategy could have produced. It answers a question a backtest cannot: how bad could it plausibly get?

QuantPower Research · Updated 6 Nov 2026 · 4 min read

This guide explains why a single backtest understates risk, the main Monte Carlo methods for trading strategies, how to read the results, a worked example and the limits of the technique.

Why one backtest is not enough

A backtest shows one path: the trades in the order they happened. But the order was partly luck. The same set of trades in a different order can produce a very different maximum drawdown, longest losing streak and final result.

If your strategy's ten worst trades happened to be spread out in history, the backtest shows a mild drawdown. If they had come together, which is entirely possible, the drawdown would have been much deeper. Monte Carlo simulation shows those possibilities.

Monte Carlo methods for trading

Reshuffling trades

Take the list of trade results from your backtest and randomly reorder them thousands of times. Each order gives a new equity curve. Total profit stays the same, but drawdowns and losing streaks change. This is the simplest method and a good starting point.

Resampling with replacement

Draw trades at random from your results, allowing the same trade to be picked more than once, until you have a sequence of the same length. Repeat thousands of times. This varies both the order and the mix of trades, so total profit changes too. It shows how sensitive results are to which trades happened.

Varying execution

Add random slippage or costs to each trade, or randomly skip a share of trades to simulate missed fills. This tests how much the strategy depends on perfect execution.

Varying parameters

Run the strategy with settings drawn randomly from a range around the chosen values. This overlaps with parameter stability testing and helps detect overfitting.

How to read the results

Monte Carlo produces a distribution, so look at percentiles rather than averages:

MetricWhat to look at
Maximum drawdownThe 95th percentile: a drawdown that 1 in 20 sequences exceeded
Longest losing streakThe 95th percentile: how many losses in a row to plan for
Final profitThe 5th percentile: a poor but plausible outcome
Risk of ruinThe share of sequences that fall below a level you cannot accept

A worked example

This is a hypothetical example.

A strategy's backtest has 200 trades with a total profit of ₹1,50,000 and a maximum drawdown of ₹40,000. After reshuffling the trades 10,000 times:

  • The median maximum drawdown is ₹46,000.
  • The 95th percentile maximum drawdown is ₹68,000.
  • The 95th percentile longest losing streak is 11 trades.

The backtest's ₹40,000 drawdown was better than most possible orders. Planning around ₹68,000 is more realistic. If ₹68,000 is more than you could tolerate, reduce the position size before going live.

Histogram of maximum drawdowns from 10,000 reshuffles of the same 200 trades, with the backtest, median and 95th percentile marked (illustration)

Using Monte Carlo for position sizing

Monte Carlo results feed directly into sizing. If you are willing to accept a maximum drawdown of ₹50,000 and the 95th percentile drawdown at one lot is ₹68,000, one lot is too large for your limit. The same logic can set a daily or monthly loss limit that is unlikely to be hit by normal bad luck, so hitting it signals that something has changed. See the position size calculator and Kelly criterion guides for other sizing methods.

Limits of Monte Carlo simulation

  • It can only reshuffle what you give it. If the backtest's trades are unrealistic, the simulations will be too.
  • It assumes trades are independent. In reality, losses often cluster, such as in volatile periods. Reshuffling breaks those clusters and can understate risk. Block methods, which reshuffle groups of consecutive trades, help.
  • It does not create new market events. A crash larger than any in your history will not appear.
  • It does not fix overfitting. An overfitted strategy's trades are the wrong input.

Treat Monte Carlo as a stress test that widens your view of risk, not as a forecast.

Where Monte Carlo fits in strategy testing

  1. Write the rules and backtest them with realistic costs.
  2. Check robustness with out-of-sample and walk-forward testing.
  3. Run Monte Carlo on the out-of-sample trades to estimate drawdowns and streaks.
  4. Size the strategy so the 95th percentile drawdown fits your limit.
  5. Paper trade, then go live small.

QuantPower's backtesting engine lists every trade, which you can use as the input for a Monte Carlo analysis. Measure the historical drawdown with the max drawdown calculator.

Start your free trial

Connect your broker, build a strategy and test it on paper before a single live order goes out.

Frequently asked questions

What is Monte Carlo simulation in trading?

A way to test a strategy by creating thousands of alternative trade sequences from its results, to see the range of possible drawdowns, streaks and outcomes.

How many simulations should I run?

Thousands. 1,000 to 10,000 runs are common, enough for the percentiles to stabilise.

Does Monte Carlo predict future returns?

No. It shows how much the results of the same trades could vary, which helps with risk planning.

Should I use reshuffling or resampling?

Reshuffling shows how order affects drawdowns. Resampling also varies the mix of trades. Using both gives a fuller picture.

Sources

  • Efron, B. and Tibshirani, R. J. (1993). An Introduction to the Bootstrap. Chapman & Hall
  • Pardo, R. (2008). The Evaluation and Optimization of Trading Strategies. Wiley
The example on this page is hypothetical. Simulated results have inherent limits and do not guarantee future performance. This guide is for education and is not investment advice.