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

Re: [amibroker] creating a basket order file



PureBytes Links

Trading Reference Links

hi,

I am still working on the making of a file that contains order lines for Interactive Brokers "basket" trading. I have been playing with a test system in AFL (see result below). But the problem still is that I want to know exactly what to sell and how many. Also I have problems starting a "fresh" file for each new backtest. But I am afraid that with only using AFL it is not possible to make this file.

I guess the solution is to use scripting and create data objects and derive the info from them. In the archives there is some stuff I found and maybe if I plough real deep something will surface ..... but could somebody direct me how to best learn to use this scripting. There is some in the manual but if there is some other place to learn this please let me know (especially about which objects and methods that can be used).

rgds, Ed





function order_func(Buy,Sell,Short,Cover,buyLimit,shortLimit,stop_long,stop_Short) {


filepath = "C:\\IBorders\\order.txt";

orderLine = 
WriteIf(LastValue(Buy) != 0,"BUY", 
WriteIf(LastValue(Short) != 0,"SHORT", 
WriteIf(LastValue(Sell) != 0,"SELL", 
WriteIf(LastValue(Cover) != 0,"COVER","")))) 
+
", "
+
Name()
+
", "
+
"STK"
+
", "
+
"SMART"
+
", "
+
"LMT"
+
", "
+
WriteIf(LastValue(Buy) != 0,NumToStr( LastValue(buyLimit), format = 1.2), 
WriteIf(LastValue(Short) != 0,NumToStr( LastValue(shortLimit), format = 1.2), 
WriteIf(LastValue(Sell) != 0,NumToStr( LastValue(stop_long), format = 1.2), 
WriteIf(LastValue(Cover) != 0,NumToStr( LastValue(stop_short), format = 1.2),"")))) 
+"\n";

fileischanged = 0;

if (LastValue(Buy) != 0 OR LastValue(Short) != 0 OR LastValue(Sell) != 0 OR LastValue(Cover) != 0) {

 if (fileischanged = 0) {
 
  filehandle = fopen(filepath, "w");
  fputs(orderLine, filehandle);
         fclose(filehandle);
         fileischanged=1;
         
        } else if (fileischanged = 1) {
        
    filehandle = fopen(filepath, "a");
  fputs(orderLine, filehandle);
         fclose(filehandle);
        }
        
} 


}


//fdelete("C:\\IBorders\\order.txt");

SetOption("MaxOpenPositions", 50 ); 
PositionSize = -15;
SetTradeDelays(0,0,0,0);

sk = StochK(8);
Buy = sk < 30;
BuyPrice = O;

Short = sk > 70;
ShortPrice = O;

Sell = 0;
Cover = 0;

ApplyStop( stopTypeNBar,stopModeBars,1,ExitAtStop = 1,Volatile = False, ReentryDelay = 1 );

SellPrice = C;
CoverPrice = C;

Equity(1);

PositionScore = 50 - StochK(8); 

Filter = (PositionScore AND Buy);

order_func(Buy,Sell,Short,Cover,BuyPrice,ShortPrice,SellPrice,CoverPrice);

[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/