here is my code:
protected override void OnBarUpdate()
{
if (State == State.Historical)
return;
myEntryOrder=EnterLongMIT(13930.00, "Long Entry");
if (barNumberOfOrder==0)
{
barNumberOfOrder=CurrentBar;
}
if (CurrentBar>barNumberOfOrder && myEntryOrder!=null)
{
CancelOrder(myEntryOrder);
Print("CancelOrder "+myEntryOrder.OrderState+" "+myEntryOrder);
}
}
log:
CancelOrder Accepted orderId='d9dcd959b40143dcbfa3c8ae3c15da65' account='Sim101' name='Long Entry' orderState=Accepted instrument='MNQ 06-21' orderAction=Buy orderType='MIT' limitPrice=0 stopPrice=13930 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=215 time='2021-04-23 14:21:18' gtd='2099-12-01' statementDate='2021-04-23'
this code is only for test cancel order
i test this code in real time, order has show in char and myEntryOrder is not null
i want the order cancel in next bar, but it's not work.
may i know what's wrong in those code?
Thanks

Comment