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

[amibroker] NinjaTrader automation AFL code



PureBytes Links

Trading Reference Links

Hello all,

NinjaTrader (www.ninjatrader.com) is a rapid order entry system that 
can control Interactive Broker's TWS.  It is similar to BracketTrader 
or any other app you might now.  It has a mode called PassThrough 
automation (http://www.ninjatrader.com/automatedtrading.htm) where, 
given signals from a tech analysis application like Amibroker, it can 
generate the order for you in TWS.

Here's some AFL code that will generate the necessary passentry.txt 
file and copies it to the ninjatrader directory.  This code requires 
the ABtool plugin found in the files section (thanks Uenal for a 
great plugin !).

///////////// NinjaTrader integration code - start //////////

fileischanged = 0;

if (LastValue(Buy) == 1) {
  mystring = "\"BUY\"" + "," + "\"" + WriteVal(numshares, 1.2) + "\"" 
+ "," + "" + "\"" + Name() + "\""  + "," + "\"STK\"" + "," + "\"\"" 
+ "," + "\"SMART\"" + ","  + "\"LMT\"" + "," + "\"" + WriteVal
(LastValue(BuyPrice),1.2) + "\"" + "," + "\"" + WriteVal
(stopprice,1.2) + "\"" + "," + "\"" + WriteVal(targetoffset,1.2) 
+ "\"" + "," + "\"" + WriteVal(stopoffset,1.2) + "\"" + "," + "\"0.01
\"" + ","  + "\"STP LMT\"" + "," +  "\"0\"" + ","  + "\"DAY\"" 
+ ",\n";

  filepath="C:\\whateverpathyouwant\\passentry.txt";
  filehandle=xxFileOpen(filepath, "w");
  temp=xxFileWriteStr(mystring, filehandle);
  temp=xxFileClose(filehandle);
  temp=xxMsgBox(mystring, "Message", 0);
  fileischanged=1;
};

EnableScript("vbscript");

<%
filechanged=AFL("fileischanged")

if filechanged then
  Set ofs = CreateObject("scripting.filesystemobject")
  MsgBox "Copying to NT directory."
  
ofs.CopyFile "C:\whateverpathyouwant\passentry.txt", "C:\ninjatrader\"
  set ofs = nothing
End if
%>

///////////// NinjaTrader integration code - end //////////


Enjoy,
HB


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get A Free Psychic Reading! Your Online Answer To Life's Important Questions.
http://us.click.yahoo.com/Lj3uPC/Me7FAA/ySSFAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

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