# What Is Monte Carlo Simulation In Trading And Investing? (Trading Simulation)

Last Updated on July 29, 2022

**Monte Carlo simulation in trading** and investing is a tool frequently used in blogs and backtests. Can Monte Carlo backtesting be used to measure risk and uncertainty? Yes, it turns out you can use it in the financial markets:

**Monte Carlo simulation and backtesting in trading (and investing) is a statistical tool to measure uncertainty and how robust your strategy is for path sequences. The simulations can make a model of the different outcomes of your trades if they had taken a different path or sequence. **

By **Monte Carlo simulation in trading** you get a better understanding of the risk and uncertainty of your trading strategy because Monte Carlo simulation lets you run your backtest thousands of times in different orders.

A backtest is at best a rough approximation of what you might expect in the future. If you do a Monte Carlo simulation you can redraw your equity curve thousands of times (in less than a second) and thus measure how likely you are to replicate your backtest in live trading (given the markets stay the same, which, of course, is highly uncertain because markets are non-stationary).

This article describes what a Monte Carlo simulation is and gives you a practical example from a trading program (Amibroker).

## Trading is all about alternative histories

We can’t judge a result solely on the end result. A good decision can produce a terrible result, and a poor decision could lead to great results. A decision has to be evaluated on the alternative or the opportunity cost. Nassim Nicholas Taleb calls this the *alternative histories *in his thought-provoking book *Fooled By Randomness*.

Alternative histories are events that could have happened but didn’t, normally due to chance and randomness. How do we know if a result is due to chance, luck, or randomness? These possible but never realized invisible alternative histories that perhaps could have taken place need to be simulated. What if the past had been slightly different? How will this influence our result?

One way to find out is by using Monte Carlo simulation:

## What is Monte Carlo simulation in trading and investing?

Monte Carlo simulation and backtesting has, of course, derived its name from the famous city and casino in Monaco. Monte Carlo is famous for its games involving random events: roulette, craps, blackjack, etc. We can argue the latter is mostly a game of skills, but nevertheless exposed to random card dealings.

Nassim Nicholas Taleb is a strong proponent of Monte Carlo simulation. The reason is that the Monte Carlo simulation lets you get a better grasp of how these alternative histories could have played out and led to completely different results. It simply shows how liable to chance and randomness your trading strategy is. What might the future bring when you start trading live?

The backtest of the trading strategy takes the trades as they happened, but what would have happened if the trade order was reshuffled? What if you had 7 consecutive losers instead of 4? Is it possible that an alternative path had twice the drawdown as the backtest?

Monte Carlo simulation examines a set of alternative trading simulations that potentially could have happened if history might have unfolded slightly differently.

For example, let’s say you had a backtest of a trading strategy that returned these trades: +3%, -1%, +7%,-2%, and +2%. The Monte Carlo simulation then uses those trades and for example reshuffles the trade order to -1%, -2 %, +7%, +2%, and +3%. The latter has two losing trades to start with and thus a higher drawdown. Was your original backtest just luck? The point with a simulation is to detect possible outcomes of the original backtest.

When you see how these alternative histories (or paths) play out, you can make better decisions on how liable you are to randomness and adjust size accordingly. Position sizing matters a lot in trading, something we will cover in a later article.

## How do you perform a Monte Carlo backtest?

The main idea behind a Monte Carlo simulation is to use random numbers to get a better understanding of the characteristics of the trading system. This can be done in many ways. Curtis Faith describes two methods in his book *Way Of The Turtle*:

- Trade scrambling: By randomly changing the order and start dates of the trades from the actual simulation and then using the percentage gain or loss from the trades to adjust equity curves.
- Equity curve scrambling: building new equity curves by assembling random portions of the original equity curve.

To give you a better understanding of how this works in practice let’s check out the process with an example:

### Monte Carlo simulation in Amibroker

To better explain, in practice, a Monte Carlo simulation, we can go through an example in Amibroker, but the process is pretty similar in every trading platform/software (we also briefly touch upon Monte Carlo simulation in our Amibroker course).

First, we need to establish the number of runs/paths/sequences/alternative histories. This simply means how many times we want to simulate the trades in a random sequence. It’s recommended to use at least 1 000 runs.

Second, we need to choose that the Monte Carlo simulation in trading takes the trades from the original backtest to create simulation runs. This mode picks randomly trades from the backtest.

Third, the position sizing should most of the time be set to the same as in the original backtest.

This is how the settings for Monte Carlo simulation look like in Amibroker:

Let’s test a strategy that has the following results in a backtest:

- 533 trades from 1993 until October 2021
- Annual returns: 14.9%
- The average gain is 0.8% per trade
- The win ratio is 74%
- The average winner is 1.68%
- The average loss is a negative 1.72%
- The profit factor is 2.9

All in all, a pretty decent strategy. Let’s apply the Monte Carlo simulation with 10 000 runs based on the settings described above. This returns the following results:

The column named “percentile” is the confidence level – a statistical term. Because the Monte Carlo simulation is based on independent runs, and you will not get the exact same result each time, it’s practical to use statistical confidence levels. The confidence level is the level we can quantify uncertainty based on the sample.

The 10% percentile shows that we can expect the strategy to go bust 10% of the time. Not very promising! But better is that we can expect the strategy to return annual returns of more than 14% 85% of the time (not shown in the table above).

However, the settings in the original backtest were done by using 100% of the equity for each trade (compounding). By using a lower equity allocation the chances for bust are reduced to zero.

### What happens if you use leverage?

Let’s test by using 2x leverage, ie. 200% of your equity. As expected, the chances of going bust are high:

## How much reliance should you put on a Monte Carlo simulation?

Monte Carlo simulations are a great tool to test your strategies, but our experience indicates you should not put too much emphasis on them. Why is that?

For example, in the example above, we have an 85% chance of getting at least 14.4% annual returns which is way better than the buy and hold, even though we could face the risk of ruin.

The answer to managing risk is to reduce size. Again, we reiterate our best rule for managing risk: always trade a smaller size than you’d like. Don’t be greedy – aim for survival.

The above example involved 100% of your equity. If you reduce the equity to around 70%, you have no chance of ruin, but the annual returns drop 2-3 percentage points. You have to use common sense to find the sweet spot.

Another argument is that a trading strategy can be very good and robust even though it “fails” a Monte Carlo simulation. We have to differentiate between being street smart vs being academic smart:

Furthermore, financial markets are non-stationary. A backtest is unlikely to replicate and markets change and evolve. Again, you have to use some street-smartness in your trading.

## Recommended reading:

- Survivorship bias in backtesting, trading, and investing
- Edward Thorp: Beating the odds â€“ the first quant
- What is a good trading strategy?
- Mark Spitznagel â€“ Safe Haven Investing
- Annie Duke â€“ Thinking In Bets
- Thoughts on Amibroker (review)
- Trading strategies
- Some valuable quotes from Nassim Nicholas Taleb

## Conclusions about Monte Carlo simulation in trading:

Simulations are a great tool to measure luck, randomness, and chance. **Monte Carlo simulation in trading** doesn’t require any time on your end as it’s built into all the trading software that exists. Anytime you perform a backtest, we recommend going to the Monte Carlo tab to see the results.

Nevertheless, don’t make hasty decisions based on the thousands of simulations. Use common sense. Markets are non-stationary and will change course frequently.