For the strategy I'm developing, I would like to design a backstop that cancels active orders if they do not fill within a certain number of bars in the unmanaged approach. What is the best way to go about doing this? I've tried searching the forum and cannot find the answer. I'm relatively new to programming, so I'm likely making a rudimentary error here. Currently I have it coded like this, but it is not working.
private Order Long = null;
private Order Short = null;
private Order BTC = null;
private Order STC = null;
private int barNumberOfOrder = 0;
protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
{
if ((OrderAction.Buy == OrderAction.Buy) && (CurrentBar > barNumberOfOrder + 5) && (execution.Order.OrderState != OrderState.Filled))
if ((OrderAction.Sell == OrderAction.Sell) && (CurrentBar > barNumberOfOrder + 5) && (execution.Order.OrderState != OrderState.Filled))
if ((OrderAction.SellShort == OrderAction.SellShort) && (CurrentBar > barNumberOfOrder + 5) && (execution.Order.OrderState != OrderState.Filled))
Any assistance, preferably with example code, is much appreciated.
Comment