Monte Carlo Simulation in Trading: Step by Step Tutorial Posted on March 23, 2016 by admin
Monte Carlo simulation is one of the most important steps in Trading system development and optimiation! "t is often overloo#ed by beginners considering the mathematical comple$ity it contains! %lso, there are hardly any articles available at "nternet &hich e$plains it in layman terms! terms! "n this post, &e'll try to e$plore the basics of Monte Carlo simulation and its advantages! %lso, &e'll go through real life e$amples to understand it thoroughly! There &ould be a follo&(up article after this &hich &ould e$plain ho& to perform Monte Carlo %nalysis in %mibro#er
What is Monte Carlo Simulation? Monte Carlo simulation is a process &hich performs repeated e$ecution of pre(defined set of steps by adding randomness to the input parameters at each iteration! The results are noted do&n at the end of each iteration &hich forms the basis of probabilistic analysis of the desired result! "n Trading terms, Monte Carlo simulation is performed to forecast the success of a bac#tested trading system! "n order to ensure that your trading system is robust, robust, bac#testing should be performed performed multiple times by adding variations to your trading rules or data! "f it gives consistent result each time, then it has a higher probability of generating profit!
Monte Carlo simulation in real world Monte Carlo simulation Monte simulation is very popul popular ar in the field of statistical statistical and scien scientific tific e$periments! e$periments! )or e$* Consider a scientist &ho &ants to estimate the tra+ectory of his space shuttle! ince the tra+ectory is highly dependent on atmospherical condition &hich is random, he has to perform Monte Carlo simulation in order to arrive at the most probable tra+ectory!-e &ill repeatedly simulate the tra+ectory by adding randomness to the atmospheric parameters after each repetition!
How to do Monte Carlo simulation in Trading? .ou need to follo& belo& 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 li#e %mibro#er! Step 1: /ptimie 1: /ptimie your Trading system rules and bac#test it! Step 2: o& 2: o& add randomness to your Trading system inputs and bac#test it again! There are multiple &ays to do this* •
Add randomness to your Trading rules: .ou rules: .ou may slightly vary your rules at each iteration and see ho& it affects your results! )or e$* "f your original uy rule is, Close should be greater than M%Close,2004, then try changing it to Close should be greater than M%Close,2014!
•
Add randomness to your Trading data: .ou data: .ou may change /-5C values by a small fraction for each iteration! )or e$* %dding 0!07 to /pen value for the specified period!
•
Add randomness to your Trade sequence: "f sequence: "f you already have a bac#tested system &ith the se8uence of trades, you can try changing this se8uence and see ho& your profitability is affected! This option is available out of the bo$ in %mibro#er for Monte Carlo simulation!
Step 3: /nc Step /nce e you bac#test bac#test it aga again, in, note do& do&n n the importan importantt out output put paramete parameters rs li# li#e e C%9 C%9:, :, ;ra&do&n, )inal e8uity etc! Step 4: :epeat 4: :epeat tep 3 and < multiple times and note do&n the results at the end of every iteration! There is no rule on the number of iteration re8uired for Monte Carlo simulation but more is better! Step 5: %nalyse 5: %nalyse your results at the end to #no& the probable success of your Trading system in all mar#et conditions! )or e$* if you bac#test 100 times by varying your inputs, and C%9: is positive in =0 occurrences, then it's highly probable that your Trading system &ould be successful!
Advantages of Monte Carlo simulation in Trading "t is a &ell(#no&n fact that >Mar#ets are :andom', so Monte Carlo simulation is a method to absorb this randomness in your Trading system! "f your system performs &ell in random mar#et conditions, then it has a huge probability of success! %t the end, everything boils do&n to probability and that is actually actua lly the basis of all profitable profitable Tr Trading ading systems! systems! "t's reall really y not enough to belie believe ve in the Trading Trading syste sy stem m +us +ustt bas based ed on pro profit fitabl able e bac bac#te #test st rep report orts! s! Mon Monte te Car Carlo lo ana analys lysis is &ei &eighs ghs e8u e8ually ally &hi &hile le designing a system!
Monte Carlo Analysis in Amibroker This art This articl icle e &il &illl out outline line the det detail ailed ed ste step p by ste step p pro proces cess s to per perfor form m Mon Monte te Car Carlo lo %n %naly alysis sis in %mibro#er! " hope you have already read our article about Monte Carlo simulation and it's importance! "f not, please find it in the belo& lin#* Monte Carlo imulation in Trading* tep by tep Tutorial elo& are the detailed steps for performing Monte Carlo %nalysis in %mibro#er*
Step 1: Create a Trading strategy &ith uy?ell rules and assignments! "f you do not have a strategy handy, refer any of our strategy posted in the past! %mibro#er Trading Trading ystems
Step 2: 9o to %nalysis@Ae& %nalysis
Step 3: "n the ne$t screen clic# on ac#tester ettings@AMonte Carlo
elo& is the description of each property available in this screen* •
Enable Monte Carlo Simulation: Simulation: This instructs the bac#test engine &hether to perform Monte Carlo simulation along &ith bac#test!
•
umber o! runs: "n runs: "n %mibro#er, %mibro#er, Monte Carlo analysis is performed by adding randomness to trade se8uence! se8uence! This prope property rty defines the numbe numberr of times the origi original nal trade se8ue se8uence nce should be randomied and bac#tested! This should be 1000 or more!
•
"osition "osit ion Si#i Si#ing: ng: ;efines the position sie to be used in each iteration of Monte Carlo simulation! "n general, &e should #eep it as same of original position sie!
•
Enable Ena ble MC Equ Equity ity cur cur$es $es:: Tu Turns rns on MC e8u e8uity ity cha charts rts in inclu cludin ding g hig highes hest, t, lo& lo&est est and average e8uity plots plus stra& broom e8uity charts4! These curves &ould be visible in Monte Carlo analysis report if enabled!
;on't change any default settings for no& and press on /B!
Step 4: Clic# on >ac#test'! This &ill generate the initial bac#test report!
Step 5: Clic# on >:eport'! "t &ould generate a detailed bac#test report as belo&*
Step : Clic# on >Monte Carlo' from the report! This &ould bring up the actual Monte Carlo analysis report as belo&*
!nterpreting t"e results: The most important thing to &atch out in the Monte Carlo %nalysis report is the table at the top of the page &ith values of some #ey statistics! %ll the graphs displayed belo& the table are generated through the table data itself! -ere are sample results highlights are added manually for the purpose of illustration4! tarting e8uity &as 10000 in this e$ample!
)irst column sho&s percentile level the value belo& &hich a given percentage of test observations realiati real iations4 ons4 fall4! o say 10th percentile tells us that 107 of time observed observed value is belo& sho&n amount! )or e$ample, the annual return value at 10th pecentile in this case (0!<174 means that 107 of tests realiations4 had annual profit less or e8ual than sho&n (0!<174! o &e can say that there is about 107 chance that our system &ould not ma#e any money &ould not brea#even4! % ma$! dra&do&n figure at =0th percentile 3!<74 means that in =07 of cases dra&do&n &ill be less t%an 3&'4&(! 3&'4&(! o in othe otherr &ords, &e can say that there is 107 of chanc chance e that it &ill be higher than that!
How to #ontrol Monte Carlo Simulation from A$%? -ere are the various et/ption commands &hich are used to control Monte Carlo imulation from %)5 directly* directly* et/ptionDMCnableE, 0 4F ?? value GG 0 disables MC simulation et/ptionDMCnableE, 1 4F ?? value GG 1 enables MC only in portfolio bac#tests default4 et/ption DMCnableE, 2 4F ?? value GG 2 forces MC to be enabled every&here in every mode including optimiation @ 5/H I4
et/ptionDMC:unsE, 1000 4F ?? define number of MC simulation runs realiations4