[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Amibroker to TradeSim Code - Help Required Please!!



PureBytes Links

Trading Reference Links

Hello All,

I've managed to find some code which allows me to export an Amibroker Exploration File to TradeSim for further analysis. This code is posted below:

 

Buy = Ref(Buy,-1); Sell = Ref(Sell, -1);

Cover = 0; Short = 0;

TradeStop = LLV(Low,10); // Initial stop for TradeSim

Equity( 1 ); // evaluates trades and stops

Filter = Sell;// OR Cover;

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);

 

Unfortunately, this code seems to work for LONG trades only. Consequently, does anyone know how I can modify it to include SHORT trades? 

I have tried to modify it myself but have run into all kinds of problems such as incorrect price data, missing price data, etc, etc.

So far I have made the following changes (which may or may not be right):

Cover = Ref(Cover , -1); Short = Ref(Short,-1);       (2nd line of code)

Filter = Sell OR Cover ;    (5th line of code)

In addition, does anyone know how I can incorporate TWO Initial Stops into the same system (1 Stop for LONG Trades and 1Stop for SHORT Trades) so that AB & TradeSim know which stop to use depending on whether the trade is LONG or SHORT??

For the system above, the initial stop for Short trades would be:     TradeStop = HHV(High,10);

 

Any help much appreciated as I'm not sure how to proceed,

 

Thanks

Chorlton

__._,_.___

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___