protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError) { // Handle entry orders here. The entryOrder object allows us to identify that the order that is calling the OnOrderUpdate() method is the entry order. if (entryOrder != null && entryOrder == order) { // Assign entryOrder in OnOrderUpdate() to ensure the assignment occurs when expected. // This is more reliable than assigning Order objects in OnBarUpdate, as the assignment is not gauranteed to be complete if it is referenced immediately after submitting entryOrder = order; // Reset the entryOrder object to null if order was cancelled without any fill if (order.OrderState == OrderState.Cancelled && order.Filled == 0) { entryOrder = null; } } }
And this entryOrder = order assignment only appears once in the whole script, which will never run when entryOrder is null initially.
I'm scratching my head and trying to figure out this bit. Could anyone shed some light on this? Thanks!
Comment