AmiBroker & Monte Carlo backtesting - Aussie Stock Forums

# Thread: AmiBroker & Monte Carlo backtesting

1. ## AmiBroker & Monte Carlo backtesting

Does Amibroker do monte carlo backtesting?

If so, how do I enable?

If not, is there some tricky way to do some sort of reasonable facsimile of MC backtesting?

TIA

2. ## Re: Amibroker & Monte Carlo backtesting

It can use javasript and such under the enablescript function- don't ask me how you would go about doing it up though. I'm as eager as you to find out about the Monte Carlo though.

3. ## Re: Amibroker & Monte Carlo backtesting

There is much conjecture re the accuracy and worthiness of Monte Carlo analysis within the tools available to the majority of traders.

True Monte Carlo analysis is used in Modelling of possible results in a scientific sence.Here EVERY variable known is entered and EVERY possible result is returned by the analysis.

As far as I know MonteCarlo as is used in a trading sence(And with the tools available) merely tests every combination of the fixed variables in a method against every possible trade combination.Similar to a probability study.

True MonteCarlo would test every concievable variable within the method as well as every combination.

4. ## Re: Amibroker & Monte Carlo backtesting

It has been discussed and I believe it is on the todo list, but do not know priority

There is an excel simulation of this posted to the amibroker yahoo group files, but not sure how well it works

What exactly is about Monte Carlo that so many people keep talking about it?

5. ## Re: Amibroker & Monte Carlo backtesting

Kave.

Here is a link which explains things reasonably well.

http://www.decisioneering.com/monte-...imulation.html

basically MonteCarlo analysis invents unknown variables and runs them against your model.
The end result is a range or deviation from the expected mean.
You can see how powerful it can be.
Often a singular tested expected result which seems profitable---can become un workable when some un avoidable variables are introduced.

A common example.

Its often thought that to follow a system you need to TAKE EVERY trade,this need not be the case and indeed with most PORTFOLIO systems cannot be done due to captal restraints.
So over a period of say 5 yrs your method may have triggered 3000 trades.
Due to capital restraints your system could only thake 300 of these trades.
Your testing shows that this was "marginally profitable" say 8% a little better than the Index.

Most (including myself) would not be excited by this and pass by this method.
However we run MonteCarlo analysis on say 50000 different potfolio combinations to see how they fair against our singular test. Results show that 30000 combinations have a 100% or better result and 10000 less than
50% and 5000 less than 20% and 10 less than 10%---our singular test was one of the WORST and the average return expected over 50000 portfolios was 70%-----------see what we could have missed.

Ive seen the same happen in reverse--- a profitable system when M/C Tested showed 95% chance of failure---but my singular test showed profit!

This is just a basic explaination hope it helps.

6. ## Re: Amibroker & Monte Carlo backtesting

thanks for that explanation tech
with AB portfolio backtesting capability you coul simulate this with adding a random() to your buy signals, or even just use it on the position score which selects which trade to take when signals exceed cash on a certain bar.
Taking multiple backtests and saving the results to excel you could create a simulation of this.

or

positionscore = random();

I have even found changing the dates by a small amount in backtesting changes the final results as the first trde taken changes, and it rolls on frm there

7. ## Re: Amibroker & Monte Carlo backtesting

Yes kave Tradesim can do Random as well.

But whats needed is the ability to do 20000 randoms!! in 2 secs.
ALL different to the next.

Yes your observation has given you the understanding of how misleading a singular testing facility like Metastock and or tradestation can be in a "PORTFOLIO" situation!

8. ## Re: Amibroker & Monte Carlo backtesting

ok so have to brush up on my typing speed, and buy much faster computer could almost make the 20000 in 3 seconds

9. ## Re: Amibroker & Monte Carlo backtesting

Kave found the 20000 simulations in 3 seconds a breeze!

LMAO!

11. ## Re: Amibroker & Monte Carlo backtesting

it's the coffee that does it

12. ## Re: Amibroker & Monte Carlo backtesting

Here you go Kavey

13. ## Re: AmiBroker & Monte Carlo backtesting

What I have discovered is my limitations with Amibroker back-testing as far as variable scenario settings. I would like the option of Monte Carlo.
Also a fixed percent position size setting relative to total equity.
I could be wrong but when I back-test with Ami. the position sizes are completely random. Setting limitation or me?

Another thing is how are stocks chosen by the back-tester considering available equity and the multiple choices meeting the trading system criteria? Alphabetically or random selection?

Do I have to buy Howards books, another plug-in or do a degree in computer sciences?

14. ## Re: AmiBroker & Monte Carlo backtesting

Originally Posted by Wysiwyg
Also a fixed percent position size setting relative to total equity.
I could be wrong but when I back-test with Ami. the position sizes are completely random.
Position sizing is covered in the portfolio backtest docs.

http://www.amibroker.com/guide/h_portfolio.html

Originally Posted by Wysiwyg
Another thing is how are stocks chosen by the back-tester considering available equity and the multiple choices meeting the trading system criteria? Alphabetically or random selection?
PositionScore is also covered in the portfolio backtest docs.

http://www.amibroker.com/guide/h_portfolio.html

By default if you haven't written a fomula to calculate position score then trades are taken alphabetically. You can also set trades to be taken randomly if you wish.

Originally Posted by Wysiwyg
Do I have to buy Howards books, another plug-in or do a degree in computer sciences?
lol, all of the above or none of the above if you choose...

Take things slowly and work through the tutorials included with Amibroker is a good first step.

15. ## Re: AmiBroker & Monte Carlo backtesting

Originally Posted by captain black
Take things slowly and work through the tutorials included with Amibroker is a good first step.
Thank you, will add the required codes. Good day to you sir.

16. ## Re: AmiBroker & Monte Carlo backtesting

Below is the amibroker code I use for monte carlo testing. I set the monteCarlo value to 0.5. Export the results, then you can create a graph in excel with CAR vs Max sys DD, or whatever you are interested in. It works well.

Mark

// PSEUDO MONTE CARLO
runs = Param("# runs", 1000, 0, 1000, 1);
monteCarlo = Param("monteCarlo", 0, 0, 1.00, 0.01);
if(monteCarlo)
Optimize("monteCarlo", 1, 1, runs, 1);

if(monteCarlo)
Buy = AND mtRandom() >= monteCarlo;
else

17. ## Re: AmiBroker & Monte Carlo backtesting

Originally Posted by r22mark
Below is the amibroker code I use for monte carlo testing. I set the monteCarlo value to 0.5. Export the results, then you can create a graph in excel with CAR vs Max sys DD, or whatever you are interested in. It works well.

Mark

// PSEUDO MONTE CARLO
runs = Param("# runs", 1000, 0, 1000, 1);
monteCarlo = Param("monteCarlo", 0, 0, 1.00, 0.01);
if(monteCarlo)
Optimize("monteCarlo", 1, 1, runs, 1);

if(monteCarlo)
Buy = AND mtRandom() >= monteCarlo;
else
Hi Mark: Could you please explain little more how does your code work? I copied it below an ami code and tried to backtest but no result!!!

tarmi

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Aussie Stock Forums