{ ** Copyright (c) 2005, NinjaTrader LLC [email protected] }
DefineDLLFunc: "NtDirect.dll", int, "Connected", int;
DefineDLLFunc: "NtDirect.dll", lpstr, "OrderStatus", lpstr;
DefineDLLFunc: "NtDirect.dll", int, "SetAllocReturnString", int;
DefineDLLFunc: "NtDirect.dll", int, "SetMaxReturnStringLength", int;
inputs:
OrderId(string);
//NTOS(stringref);
SetAllocReturnString(1); { alloc memory for returned string, TS will free that memory }
SetMaxReturnStringLength(2); { limit the max length of return string to 500 }
if Connected(0) = 0 then begin
//NTOrderStatusA = "OK";
NTOrderStatusA = "None";
if OrderStatus(OrderID) = "Wo" then NTOrderStatusA = "Working" else
if OrderStatus(OrderID) = "Fi" then NTOrderStatusA = "Filled" else
if OrderStatus(OrderID) = "Pa" then NTOrderStatusA = "PartFilled" else
if OrderStatus(OrderID) = "Ca" then NTOrderStatusA = "Cancelled" else
if OrderStatus(OrderID) = "Pe" then NTOrderStatusA = "Pending";
end;
Strategy Code Excerpt:
case 1://both long and short active
//LONG FIRST TRADE
if time = 833
and barstatus(1) = 2
and NTLE2Sent = false
then begin
value1 = NTCommand("PLACE",NTAcct,"Buy",NTContracts,"Limit",LEP,0,"Day","",NTLE2,"","");
fileappend(NTLogFile,formattime("hh:mm:ss tt",computerdatetime)+S5+"Buy"+S5+numtostr(NTContracts,0)+" @ "+numtostr(LEP,2)+" Limit"+S5+NTLE2+newline);
NTLE2Sent = true;
end;
//WHEN INITIAL ORDER BEGINS TO FILL, PLACE EXIT AND REVERSAL ORDERS
if time > 833
and instr(NTOSNTLE2,"Filled") > 0
and NTLX2Sent = false
then begin
value1 = NTCommand("PLACE",NTAcct,"Sell",NTContracts,"Limit",SEP,0,"Day","",NTLX2,"","");
fileappend(NTLogFile,formattime("hh:mm:ss tt",computerdatetime)+S5+"Sell"+S5+numtostr(NTContracts,0)+" @ "+numtostr(SEP,2)+" Limit"+S5+NTLX2+newline);
NTLX2Sent = true;
end;

Comment