This guide outlines a comprehensive step-by-step process for conducting a Monte Carlo Analysis in Amibroker. Ensure you’ve read our Mastering Monte Carlo Simulation.
Create a trading strategy with buy/sell rules and assignments. If you need a strategy, refer to our Amibroker Trading Systems.
Go to Analysis → New Analysis
In the next screen, click on Backtester Settings → Monte Carlo.
Here’s what each property in this screen means:
- Enable Monte Carlo Simulation: Enables or disables Monte Carlo simulation with backtests.
- Number of runs: Determines how many times the original trade sequence is randomized and backtested (should be 1000 or more).
- Position Sizing: Sets position size for each iteration of the Monte Carlo simulation (usually the same as the original).
- Enable MC Equity curves: Displays MC equity charts in the Monte Carlo analysis report.
Don’t change default settings and click OK.
Click ‘Backtest’ to generate the initial backtest report.
Click ‘Report’ to generate a detailed backtest report.
Click ‘Monte Carlo’ to view the Monte Carlo analysis report.
Interpreting the results:
Focus on the table at the top of the Monte Carlo Analysis report, which provides key statistics. The graphs below are generated from this table data. Here’s an example:
The first column shows percentile levels, indicating where a given percentage of test observations fall. For instance, the 10th percentile represents the percentage of tests with an annual profit equal to or below -0.41%. This helps assess the likelihood of various outcomes.
How to control Monte Carlo Simulation from AFL?
Use these SetOption commands to control Monte Carlo Simulation directly from AFL:
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)