Monte Carlo Simulation in Trading: Step by Step Tutorial

Monte Carlo simulation is one of the most important steps in Trading system development and optimization. It is often overlooked by beginners considering the mathematical complexity it contains. Also, there are hardly any articles available at Internet which explains it in layman terms. In this post, we’ll try to explore the basics of Monte Carlo simulation and its advantages. Also, we’ll go through real life examples to understand it thoroughly. There would be a follow-up article after this which would explain how to perform Monte Carlo Analysis in Amibroker.

What is Monte Carlo Simulation?

Monte Carlo simulation is a process which performs repeated execution of pre-defined set of steps by adding randomness to the input parameters at each iteration. The results are noted down at the end of each iteration which forms the basis of probabilistic analysis of the desired result. In Trading terms, Monte Carlo simulation is performed to forecast the success of a backtested trading system. In order to ensure that your trading system is robust,  backtesting should be performed multiple times by adding variations to your trading rules or data. If it gives consistent result each time, then it has a higher probability of generating profit.

Monte Carlo simulation in real world

Monte Carlo simulation is very popular in the field of statistical and scientific experiments. For ex: Consider a scientist who wants to estimate the trajectory of his space shuttle. Since the trajectory is highly dependent on atmospherical condition which is random, he has to perform Monte Carlo simulation in order to arrive at the most probable trajectory.He will repeatedly simulate the trajectory by adding randomness to the atmospheric parameters after each repetition.

How to do Monte Carlo simulation in Trading?

You need to follow below steps to perform Monte Carlo analysis for your Trading system. Please note that these steps can be performed manually or by using any Trading platform like Amibroker.

Step 1: Optimize your Trading system rules and backtest it.

Step 2: Now add randomness to your Trading system inputs and backtest it again. There are multiple ways to do this:

  • Add randomness to your Trading rules: You may slightly vary your rules at each iteration and see how it affects your results. For ex: If your original Buy rule is, Close should be greater than EMA(Close,200), then try changing it to Close should be greater than EMA(Close,201).
  • Add randomness to your Trading data: You may change OHLC values by a small fraction for each iteration. For ex: Adding 0.05% to Open value for the specified period.
  • Add randomness to your Trade sequence: If you already have a backtested system with the sequence of trades, you can try changing this sequence and see how your profitability is affected. This option is available out of the box in Amibroker for Monte Carlo simulation.

Step 3: Once you backtest it again, note down the important output parameters like CAGR, Drawdown, Final equity etc.

Step 4: Repeat Step 3 and 4 multiple times and note down the results at the end of every iteration. There is no rule on the number of iteration required for Monte Carlo simulation but more is better.

Step 5: Analyse your results at the end to know the probable success of your Trading system in all market conditions. For ex: if you backtest 100 times by varying your inputs, and CAGR is positive in 90 occurrences, then it’s highly probable that your Trading system would be successful.

Advantages of Monte Carlo simulation in Trading

It is a well-known fact that ‘Markets are Random’, so Monte Carlo simulation is a method to absorb this randomness in your Trading system. If your system performs well in random market conditions, then it has a huge probability of success. At the end, everything boils down to probability and that is actually the basis of all profitable Trading systems. It’s really not enough to believe in the Trading system just based on profitable backtest reports. Monte Carlo analysis weighs equally while designing a system.

Performing Monte Carlo analysis manually would definitely be a tedious and time consuming job. Thats is the reason all modern Trading platforms like Amibroker have an inbuilt functionality for it. Check out the below article which would help you the process of executing Monte Carlo simulation in Amibroker.

Monte Carlo Analysis in Amibroker

One Comment

  1. Monte Carlo simulation is a powerful tool to assess risk. The most important factor is the quality of inputs. Garbage in, garbage out. Thanks for the application to trading.

Leave a Reply

Your email address will not be published. Required fields are marked *