Monte Carlo Analysis in Amibroker

This article will outline the detailed step by step process to perform Monte Carlo Analysis in Amibroker. I hope you have already read our article about Monte Carlo simulation and it’s importance. If not, please find it in the below link:

Monte Carlo Simulation in Trading: Step by Step Tutorial

Below are the detailed steps for performing Monte Carlo Analysis in Amibroker:

Step 1:

Create a Trading strategy with Buy/Sell rules and assignments. If you do not have a strategy handy, refer any of our strategy posted in the past.

Amibroker Trading Systems

Step 2:

Go to Analysis–>New Analysis

New Analysis Window

Step 3:

In the next screen click on Backtester Settings–>Monte Carlo

Monte Carlo Settings

Below is the description of each property available in this screen:

  • Enable Monte Carlo Simulation: This instructs the backtest engine whether to perform Monte Carlo simulation along with backtest.
  • Number of runs: In Amibroker, Monte Carlo analysis is performed by adding randomness to trade sequence. This property defines the number of times the original trade sequence should be randomized and backtested. This should be 1000 or more.
  • Position Sizing: Defines the position size to be used in each iteration of Monte Carlo simulation. In general, we should keep it as same of original position size.
  • Enable MC Equity curves: Turns on MC equity charts (including highest, lowest and average equity plots plus straw broom equity charts). These curves would be visible in Monte Carlo analysis report if enabled.

Don’t change any default settings for now and press on OK.

Step 4:

Click on ‘Backtest’. This will generate the initial backtest report.

Backtest Results

Step 5:

Click on ‘Report’. It would generate a detailed backtest report as below:

Backtest Report

Step 6:

Click on ‘Monte Carlo’ from the report. This would bring up the actual Monte Carlo analysis report as below:

Monte Carlo Results

Interpreting the results:

The most important thing to watch out in the Monte Carlo Analysis report is the table at the top of the page with values of some key statistics. All the graphs displayed below the table are generated through the table data itself. Here are sample results (highlights are added manually for the purpose of illustration). Starting equity was 10000 in this example.

Monte Carlo Table

First column shows percentile level (the value below which a given percentage of test observations (realizations) fall). So say 10th percentile tells us that 10% of time observed value is below shown amount. For example, the annual return value at 10th pecentile (in this case -0.41%) means that 10% of tests (realizations) had annual profit less or equal than shown (-0.41%). So we can say that there is about 10% chance that our system would not make any money (would not breakeven). A max. drawdown figure at 90th percentile (38.48%) means that in 90% of cases drawdown will be less than 38.48%. So in other words, we can say that there is 10% of chance that it will be higher than that.

How to control Monte Carlo Simulation from AFL?

Here are the various SetOption commands which are used to control Monte Carlo Simulation from AFL directly:

SetOption(“MCEnable”, 0 ); // value == 0 disables MC simulation

SetOption(“MCEnable”, 1 ); // value == 1 enables MC only in portfolio backtests (default)

SetOption( “MCEnable”, 2 ); // value == 2 forces MC to be enabled everywhere (in every mode including optimization – SLOW !)

SetOption(“MCRuns”, 1000 ); // define number of MC simulation runs (realizations)

Leave a Reply

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