Rajandran R Founder of Marketcalls and Co-Founder Algomojo. Full-Time Derivative Trader. Expert in Designing Trading Systems (Amibroker, Ninjatrader, Metatrader, Python, Pinescript). Trading the markets since 2006. Mentoring Traders on Trading System Designing, Market Profile, Orderflow and Trade Automation.

Monte Carlo Analysis using Amibroker

1 min read

Monte Carlo Analysis is a process of validating the robustness of the Trading Strategy. With Monte Carlo Analysis we can simulate set of Equity curves using random numbers from the backtest data. These large sets of simulations are then used to find the likely probability distribution of an unseen risk in trading the strategy.

Monte Carlo Simulation performs trial runs using combination of positions from your trading system (backtested data) and collects statistics. You can use the statistics to analyze the characteristics of your trading systems.

AmiBroker in its recent version 5.94 beta onwards released a built-in Monte Carlo simulator which is high speed (30+ million trades per second) simulator. It uses high-quality Mersene Twister random number generator. Probably one can expect to access Monte Carlo Simulator in its upcoming major release upgrade (Amibroker Version 6.0 onwards).

Monte Carlo Settings in Amibroker
Monte Carlo Settings

 
Following are the Input Parameters in Monte Carlo Settings available under backtester settings section in New Analysis

“Enable Monte Carlo Simulation” – turns on/off MC simulator

“Number of runs” – defines how many MC simulation runs is done (default value is 1000)

“Position sizing” – defines position sizing used by Monte Carlo simulator.

“Enable MC Equity Curves” – Enable MC (Min/Max/Avg) Equity Curves CDF Charts statistics

In Amibroker Monte Carlo Analysis is readily available in the backtest report once the backtest is done. The output statistics is set of CDF Charts (Cumulative Distribution Function Charts). MC Min/Max Equity, MC Final Equity, MC CAR, MC Max Drawdown $ and %, Lowest Equity are the output statistics from Monte Carlo Analysis. And one can access these reports from the Backtesting report from Amibroker v5.96 beta onwards.

MC Final Equity CDF Charts
MC Final Equity

Above chart shows the terminal equity level percentile. You can find out for a specific equity level, the percentile of trials that are above/below the level. Terminal equity level is the final equity value after a trial is run.

Above MC Final Equity is the cumulative result of 1000 simulated runs with a sample strategy. From the CDF charts 30% of the trial runs generated equity retuns between 7,50,000 and 12,50,000 returns. And rest of the 70% of the trail runs are able to generate more than 12,50,000 profits with a Initial Capital of 2,00,000. Every time you do backtest you will get different output statistics due to random generation of Equity Curve.

Sample Backtest Report with Monte Carlo Analysis

Monte Carlo Report

To enable Monte Carlo simulation in each backtest of optimization process and each individual backtest at code level one can
SetOption( “MCEnable”, 2 ); // value == 2 forces MC to be enabled everywhere (in every mode including optimization).

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

Monte Carlo will help you in understand the robustness of the trading system and idenifty the problem with the trading strategy but Monte Carlo analysis will not solve the problem in your trading system. To put it in simple words it is just a validation process. To create a better trading system the trader should adapt better trading design principles to improve his/her trading system performance.

If you are using lower version of Amibroker still one can perform Monte Carlo analysis using Amibroker alongwith Ms Excel which we will be discussing in the upcoming articles.

Rajandran R Founder of Marketcalls and Co-Founder Algomojo. Full-Time Derivative Trader. Expert in Designing Trading Systems (Amibroker, Ninjatrader, Metatrader, Python, Pinescript). Trading the markets since 2006. Mentoring Traders on Trading System Designing, Market Profile, Orderflow and Trade Automation.

AllinOneAlerts – Amibroker Alerts Module for Algomojo Users

AllinOneAlerts is one of the most important and most requested modules is to bring all sorts of alerts with few lines of coding efforts....
Rajandran R
58 sec read

Stop and Reverse Cover Orders/Bracket Orders – Automated Chart…

Bracket Order and Cover Order are multi-legged orders which come with default protection with stop loss with reasonable intraday leverage. This tutorial focus...
Rajandran R
11 min read

Exiting Cover Order and Bracket Order for a Particular…

Bracket Order and Cover Order are multi legged orders and cancelling the bracket order and cover order for a particular trading instrument there are...
Rajandran R
1 min read

5 Replies to “Monte Carlo Analysis using Amibroker”

  1. I want to learn Market Profile. I am based in Kolkata, West Bengal. Please revert back at the earliest. My no. is 9831921712

  2. Hi Rajandran, I am trying to learn AFL. I want to do the following:

    if ADX(14) is greater than 70{
    Paint Chart candle Red}
    else if ADX (14) is less than 25 {
    Paint Chart candle Green}
    else {
    Paint Chart Candle Gray}

    can you help

  3. Interesting article but would you care to elaborate what are the expected parameters of a robust system and what kind of systems should be avoided on the basis of the results of the simulation.

    I understand that it differs from trader to trader but I am looking for a ball park estimate.

Leave a Reply

Get Notifications, Alerts on Market Updates, Trading Tools, Automation & More