IsLiveTrading = LastBarOnChart and NTConnected(0) and (IsLiveTrading[1] or DateToJulian(Date) >= DateToJulian(CurrentDate) - 1);
if IsLiveTrading and BarStatus(1) = 2 then begin
vars: Order.Position(0), Order.OpenContracts(0), Order.EntryBar(0);
Value1 = NTMarketPosition("Sim101");
Order.Position = Sign(Value1);
Order.OpenContracts = AbsValue(Value1);
vars: Live.Pending.Id("");
if Order.Position = 0 and Live.Pending.Id = "" then begin
Live.Pending.Id = "";
Value9 = NTBuyMarket(Live.Pending.Id, 10);
print("Buy " + numtostr(Close, GTG.TickPrecision) + " on " + numtostr(CurrentBar, 0));
Order.EntryBar = CurrentBar;
end else begin
print("Order is open on Current Bar " + numtostr(CurrentBar, 0));
if Live.Pending.Id <> "" and NTFilled(Live.Pending.Id) = 10 then begin
Live.Pending.Id = "";
print("Order is Filled");
end;
if CurrentBar = Order.EntryBar + 2 then begin
Value9 = NTClosePosition("Sim101");
// NTSellMarket(NTNewOrderId, 10);
print("NTClosePosition");
end;
end;
end;

Comment