if((error == ErrorCode.OrderRejected) || (orderState == OrderState.Rejected))
{
msg = string.Format("Order status = {0}, Market Postiion = {1}, order name = {2}, order signal = {3}", orderState, Position.MarketPosition, order.Name, order.FromEntrySignal);
Print(msg);
if(order.Name == "LongDumpling")
{
msg = string.Format("Market position is Flag and signal is Long Dumpling with entry of = {0} and current bar at {1}", Entry_Price_L, CurrentBars[1]);
Limit_order = EnterLongLimit(3, Entry_Price_L, "LongDumpling");
limit_bar_number = CurrentBars[1];
}
else if(order.Name == "ShortDumpling")
{
msg = string.Format("Market position is Flag and signal is Short Dumpling with entry of = {0} and current bar at {1}", Entry_Price_L, CurrentBars[1]);
Limit_order = EnterShortLimit(3, Entry_Price_S, "ShortDumpling");
limit_bar_number = CurrentBars[1];
}
Print(msg);
}
}
i want to cancel the order after 1 bar. So i call this routine on onbarupdate
f(((CurrentBars[1] - limit_bar_number) >0) && (limit_bar_number != 0))
{
if((Limit_order.OrderState != OrderState.Filled) && (Limit_order.OrderState != OrderState.Cancelled) )
{
CancelOrder(Limit_order);
msg = string.Format("Cancelling Limit Order, Position Flat and signal is Long Dumpling with entry of = {0} and current bar at {1}", CurrentBars[1] , limit_bar_number);
Print(msg);
}
}
}
I can the the print below the cancel order however the Cancel routine does not appear to work.
Comment