The following code does this just fine, except TS sends more than one order for the triggering bar when intrabarordering is set to true. This raises two questions regarding this interface:
How can I get just a single order processed?
Why can't NTMarketPosition see that the first intrabar order is placed and prevent the second from being generated.
[IntraBarOrderGeneration = TRUE]
{DefineDLLFunc: "NTDirect.dll", int, "Setup", lpstr, int;}
inputs: numContracts(2);
variables: nHigh(9999999), nLow(-1);
variables: success(0);
if Date = {CurrentDate} 1071012 then begin
if Date <> Date[1] then
begin
nHigh = High;
nLow = Low;
end;
if NTConnected(1) then
begin
{go long if price > high of 1st bar }
if High > nHigh and NTMarketPosition("") = 0 then
begin
success = NTBuyMarket("FirstBar",numContracts);
nHigh = 99999999;
nLow = -1;
end;
if Low < nLow and NTMarketPosition("") = 0 then
begin
success = NTSellMarket("FirstBar",numContracts);
Print(File("c:\mydata.txt"), "SELL ",CurrentBar, "Date " ,Date, Time, Close, "High: ", High, " LOW: ", Low," NHigh: ", nHigh, " NLOW: ", nLow );
nHigh = 99999999;
nLow = -1;
end;
end;
end; {currentdate}

Comment