Australian (ASX) Stock Market Forum

AmiBroker to TradeSim & Monte Carlo testing

Joined
Feb 12, 2006
Posts
202
Reactions
0
Recently a couple of people have asked me how they could get output from Amibroker into TradeSim for testing.

There are some posts on the Amibroker Yahoo site on this topic that are well worth a read.

For starters: http://finance.groups.yahoo.com/group/amibroker/message/113685 - Franc (oceanchimes on yahoo) is right up there in terms of coding ability! I have used this code for some time and it works.

Also have a look at: http://finance.groups.yahoo.com/group/amibroker/message/87268 if you want to roll your own or understand it a little more.

I modified the following code from the second link above. At the moment it works but the dates have to be converted using Excel so that TradeSim can use it.

Code:
// Explorer Output for TradeSim
 // Trades may need to be delayed
 Buy = Ref(Buy,-1); Sell = Ref(Sell, -1);
 Cover = 0; Short = 0;
 TradeStop = exit;// Initial stop for TradeSim - alter as necessary
 
 Equity( 1 ); // evaluates trades and stops 
 Filter = Sell;// OR Cover;  // Not set up for short trades at this stage
 
 IsLong = Sell; 
 
 dt = DateTime(); 
 
 // Determine values for Explorer
 EntryDate = IIf( IsLong, ValueWhen( Buy, dt ), ValueWhen( Short, dt ) ); 
 ExitDate = dt; 
 EntryPrice = IIf( IsLong, ValueWhen( Buy, BuyPrice ), ValueWhen( Short, ShortPrice ) );  // Set buy and sell prices to Open for TradeSim
 ExitPrice = IIf( IsLong, SellPrice, CoverPrice ); 
 EntryLow = IIf( IsLong, ValueWhen( Buy, L ), ValueWhen( Short, L ) ); 
 EntryHigh = IIf( IsLong, ValueWhen( Buy, H ), ValueWhen( Short, H ) ); 
 EntryVolume = IIf( IsLong, ValueWhen( Buy, Ref(V,-1) ), ValueWhen( Short, Ref(V, -1) ) ); 
 InitialStop = IIf( IsLong, ValueWhen( Buy, TradeStop ), ValueWhen( Short, TradeStop ) ); 
 ExitLow = L; 
 ExitHigh = H;
 
 SetOption("NoDefaultColumns", True ); 
 
 AddTextColumn( Name(), "Symbol" ); 
 AddColumn( IIf( IsLong, 76, 83 ), "Long/Short", formatChar ); // L or S letter 
 AddColumn( EntryDate, "EntryDate", formatDateTime); 
 AddColumn( ExitDate, "ExitDate", formatDateTime); 
 AddColumn( InitialStop, "Initial Stop", 1.3 ); 
 AddColumn( EntryPrice, "EntryPrice", 1.3 ); 
 AddColumn( ExitPrice, "ExitPrice", 1.3 ); 
 AddColumn( EntryLow, "EntryLow", 1.3 ); 
 AddColumn( EntryHigh, "EntryHigh", 1.3 ); 
 AddColumn( L, "ExitLow", 1.3 ); 
 AddColumn( H, "ExitHigh", 1.3 ); 
 AddColumn( EntryVolume, "EntryVolume", 0.0);
Output directly to a TradeSim compatible file is possible by reformatting the dates in AFL and using the output approach from the second link above. Someone might want to have a go!

For those without TradeSim it is possible to use AmiBroker and Excel to do some Monte Carlo testing - try a search on this site for more details (it's here somewhere).

regards
stevo
 

Cam

Joined
Oct 12, 2009
Posts
26
Reactions
0
Stevo,

I have always thought AB was the perfect reply to Metastock/TradeSim. Does AB have backtesting limitations compared to Metastock/TradeSim because I have the latter. Thinking about buying AB. Do I need it or am I about to waste my money?
 
Joined
Apr 14, 2007
Posts
317
Reactions
0
Stevo,

I have always thought AB was the perfect reply to Metastock/TradeSim. Does AB have backtesting limitations compared to Metastock/TradeSim because I have the latter. Thinking about buying AB. Do I need it or am I about to waste my money?
Sorry to butt in (as the question was directed to Stevo) but IMO AB is a great piece of software, especially considering its price. The learning curve is a little more steeper, compared to say MS, but IMO it is worth it as AB has greater flexibility when it comes to coding possibilities.

I use it with TradeSim as I believe Tradesim's Monte Carlo Analysis is far superior to anything else on the market. Some will argue that Monte Carlo can be done with AB by exporting the tradefile to a dedicated excel spreadsheet but IMO the way that the Monte Carlo is performed is not as good compared to the method used with TradeSim. From what I understand, TradeSim's approach to Monte Carlo tries to mimic what would happen in real-life trading...

It is worth noting that AB does have a function called Position Score which allows one to "Rank" trades but again IMO this is different to performing true Monte Carlo Analysis.

Chorlton
 

Cam

Joined
Oct 12, 2009
Posts
26
Reactions
0
Thanks Chorlton,

I gues I should get AmiBroker - I really like the look of it. The coding worries me a bit but I think I will be able to learn enough - just have to put the hours in.

Hey is your forum name taken from kids show from over 30 years ago with a dragon named Chorlton, the wheelies, the spikies and a witch that lived in a kettle?
 
Joined
Apr 14, 2007
Posts
317
Reactions
0
Thanks Chorlton,

I gues I should get AmiBroker - I really like the look of it. The coding worries me a bit but I think I will be able to learn enough - just have to put the hours in.

Hey is your forum name taken from kids show from over 30 years ago with a dragon named Chorlton, the wheelies, the spikies and a witch that lived in a kettle?
There's plenty of AB users on here who can help out with coding issues....

Ref. Chorlton, 100% correct !! ;)
 
Joined
Feb 12, 2006
Posts
202
Reactions
0
Cam
I haven't been visiting ASF for some time. AB is definitely not a waste of money. I did have Metastock for some years but changed over in 2003 (or thereabouts). No regrets since AB is an excellent product.

Anything that MS and Tradesim can do AB can do (although sometimes not as flexible), but old habits die hard and I still will double check a system on TradeSim. You can also have a lot of fun with AB and Excel or similar software as shown by the charts below.
 

Attachments

Joined
Jul 14, 2005
Posts
43
Reactions
0
Cam
I haven't been visiting ASF for some time. AB is definitely not a waste of money. I did have Metastock for some years but changed over in 2003 (or thereabouts). No regrets since AB is an excellent product.

Anything that MS and Tradesim can do AB can do (although sometimes not as flexible), but old habits die hard and I still will double check a system on TradeSim. You can also have a lot of fun with AB and Excel or similar software as shown by the charts below.
AB cannot do Monte Carlo fast enough so they down play that feature and instead promote portfolio optimization and walk forward testing which is an over simplification of an otherwise complex problem and totally flawed IMHO.

We added a Parametric Sweep function to the latest version of TradeSim Enterprise and this requires even more computational resources. For example, stepping a parameter 20 times in AB optimization would require 20 simulations. With the Parametric sweep facility and 5000 simulations per step would require 100,000 simulations. This is quite easily accommodated with TradeSim without having to wait months to finish it and provides infinitely more information which is hidden by an otherwise over simplified optimization process.

ParametricSweep100%25.png
 

Attachments

Joined
Feb 12, 2006
Posts
202
Reactions
0
Tradesim

Nice!

With Monte Carlo TradeSim is very fast when compared to Amibroker.

I am wondering if it's possible to implement the Parametric Sweep with Amibroker / Tradesim combination? I will have to have a look (and upgrade my TradeSim version as well).

stevo
 
Joined
Apr 14, 2007
Posts
317
Reactions
0
AB cannot do Monte Carlo fast enough so they down play that feature and instead promote portfolio optimization and walk forward testing which is an over simplification of an otherwise complex problem and totally flawed IMHO.

We added a Parametric Sweep function to the latest version of TradeSim Enterprise and this requires even more computational resources. For example, stepping a parameter 20 times in AB optimization would require 20 simulations. With the Parametric sweep facility and 5000 simulations per step would require 100,000 simulations. This is quite easily accommodated with TradeSim without having to wait months to finish it and provides infinitely more information which is hidden by an otherwise over simplified optimization process.

http://www.compuvision.com.au/ParmetricSweep.htm

ParametricSweep100%25.png
David,

Firstly, Great Job !!! TradeSim is evolving from strength to strength and this latest addition will only help to reinforce that!!

One question though. With the Parametric Sweep feature, I am correct in assuming that one will need to use new MS functions to be able to capture the relevant data (ie. the variables to be optimised) from MS, for use within TradeSim?

I ask as I currently use AB & TradeSim (instead of the recommened MS-TradeSim combo) and consequently, I'm concerned that I won't be able to utilise these new features.

The other option is to purchase MS but this would then mean that I would need to recode all my strategies into MS and given some of their complexity this is probably beyond my scope.
 

Attachments

Joined
Jul 14, 2005
Posts
43
Reactions
0
David,

Firstly, Great Job !!! TradeSim is evolving from strength to strength and this latest addition will only help to reinforce that!!

One question though. With the Parametric Sweep feature, I am correct in assuming that one will need to use new MS functions to be able to capture the relevant data (ie. the variables to be optimised) from MS, for use within TradeSim?

I ask as I currently use AB & TradeSim (instead of the recommened MS-TradeSim combo) and consequently, I'm concerned that I won't be able to utilise these new features.

The other option is to purchase MS but this would then mean that I would need to recode all my strategies into MS and given some of their complexity this is probably beyond my scope.
The parameters being stepped are the trading parameters within TradeSim itself so it doesn't matter how the trade database is created.

Later on we will add the ability to do a similar thing with a list of different trade databases created from stepping the system variables as is done in the normal optimization procedure. However unlike a conventional optimization each time a variable is stepped a Monte Carlo analysis is run.

As you can see there is a lot more information that is obtained using this method and even after running a sweep it is not just a simple matter of picking an optimum value due to the statistical variance from each Monte Carlo run.

Regards
David
 
Joined
Apr 14, 2007
Posts
317
Reactions
0
The parameters being stepped are the trading parameters within TradeSim itself so it doesn't matter how the trade database is created.

Later on we will add the ability to do a similar thing with a list of different trade databases created from stepping the system variables as is done in the normal optimization procedure. However unlike a conventional optimization each time a variable is stepped a Monte Carlo analysis is run.

As you can see there is a lot more information that is obtained using this method and even after running a sweep it is not just a simple matter of picking an optimum value due to the statistical variance from each Monte Carlo run.

Regards
David

Thanks for the reply...........
 
Joined
Jul 14, 2005
Posts
43
Reactions
0
Tradesim

Nice!

With Monte Carlo TradeSim is very fast when compared to Amibroker.

I am wondering if it's possible to implement the Parametric Sweep with Amibroker / Tradesim combination? I will have to have a look (and upgrade my TradeSim version as well).

stevo
Yes the procedure is no different to using MetaStock as the parameter stepping is done within TradeSim.

regards
david
 
Joined
Apr 7, 2009
Posts
4
Reactions
0
hi guys
looking to buy tradesim with either bullcharts or amibroker (probably both).
Is tradesims enterprise version worth the extra for a private trader?
Any opinions would be appreciated.
thanks guys
 
Joined
Apr 14, 2007
Posts
317
Reactions
0
hi guys
looking to buy tradesim with either bullcharts or amibroker (probably both).
Is tradesims enterprise version worth the extra for a private trader?
Any opinions would be appreciated.
thanks guys

Depends on the individual I guess.

I use it, and for me, it has probably saved me more than its original cost by not trading strategies which initially seemed profitable but from extensive testing proved unsuccessful over the long-term.

Coupled with a decent charting package it is a powerful tool to have in ones arsenal especially if one is really interested in developing robust strategies.
 
Joined
Apr 7, 2009
Posts
4
Reactions
0
Thanks Chorlton

Did it take you a while to learn the program?

Have been using MS eod 7 for just on 10 years and looking to change to bullcharts or amibroker and test some ideas using tradesim.

Might just start off with the pro version and see how it goes.
cheers
 
Joined
Apr 14, 2007
Posts
317
Reactions
0
Thanks Chorlton

Did it take you a while to learn the program?

Have been using MS eod 7 for just on 10 years and looking to change to bullcharts or amibroker and test some ideas using tradesim.

Might just start off with the pro version and see how it goes.
cheers
TradeSim is a powerful product and to get the most out of it you would want to dedicate sufficient time to learn its many features. Its very user-friendly though and the creator (David) is always on hand if you have real problems. I've emailed him at all hours of the day and night and he has almost always responded immediately. I'm convinced he doesn't sleep !!

Also, there are a number of users of TradeSim on here and other forums, so if you ever get stuck there are people that can offer help.

I would add (and this is only my opinion) that if you are serious about testing strategies then you need to have the capability to run Monte Carlo tests. This unfortunately means you need the Enterprise Edition which is a lot more expensive than the other two versions.

I remember when I first started looking at TradeSim I wasn't sure whether the added expense for the Enterprise Edition was really worth it. However, after spending the last year or so looking at strategies and developing my own systems, I now realise that its a very good investment !!! What you learn from using it will save you $$$ in the long run........
 
Joined
Jul 8, 2014
Posts
36
Reactions
0
Hi,

Is anyone using Amibroker & Tradesim?

I have Amibroker (new user). I want to know what features Tradesim offers that I cannot get in Amibroker?

I can see that this thread has been previously discussed. However given the time that has passed I presume both programs have been through several updates. Thus looking for some current feedback.

With thanks

Regards,

Tradezy
 
Joined
Jun 13, 2007
Posts
838
Reactions
107
Hi Tradezy --

I have made several posts related to TradeSim over the past several years. Search for them, read them, think about how you will be using TradeSim.

Tools are definitely improving. There are several options for doing Monte Carlo analysis related to trading system development that were not available when some of the posts were made, and there are new and much more powerful tools coming. Post back with what you hope to accomplish.

Best regards,
Howard
 
Joined
Mar 31, 2012
Posts
413
Reactions
19
Monte Carlo is a pretty basic process being easier than actual backtesting. It's some math learned by kids in elementary school applied on data after backtest is done (shuffling trades generated by backtest).

Simple custom Monte Carlo AFL in AmiBroker http://i.imgur.com/EGbQfMo.gif
 
Joined
Jul 8, 2014
Posts
36
Reactions
0
Hi Tradezy --

I have made several posts related to TradeSim over the past several years. Search for them, read them, think about how you will be using TradeSim.

Tools are definitely improving. There are several options for doing Monte Carlo analysis related to trading system development that were not available when some of the posts were made, and there are new and much more powerful tools coming. Post back with what you hope to accomplish.

Best regards,
Howard
Hi Howard,

Thanks for the info. I have been reading through the posts. I'll have another look.

Amibroker can be used for Backtesting, Optimization & Walkforward testing (in/ out sample data). It can accommodate fixed or dynamic money management (position sizing/ risk adjusting as capital increases/ decreases). Although I have not used it as yet it can Rank trades.

Does Tradesim offer benefits over Amibroker when it comes to: Backtesting, Optimization & Walkforward testing?

Bearing in mind I still have wet feet, I believe Amibroker is limited in regards to:
- No Monte Carlo testing, unless there is a random function/ code that I have not understood yet. This would be helpful in regards to profit, draw down, position size analysis.
- Optimization slowness (I can live with this)
- Unable to pyramid in with "Applystop" stop loss (maybe I need to use Looping - I am not there yet)

Tradesim can randomize the trading sequence. However are there any other benefits to having Tradesim? Or perhaps I am better with another program for Monte Carlo?

With thanks again,

Regards,

Tradezy

PS Apologies if this message duplicates, I was logged out while trying to submit on my last attempt
 
Top