- Joined
- 12 February 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.
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
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