Dear all,

I use the OnOrderEvent(self, event) method in the algorithm whose code is attached to this post. However, I believe the code block is never executed (despite orders being filled) since I have debug/log messages in this code block that do not appear. 

def OnOrderEvent(self, event): # Handle filling of buy & sell orders: # Determine if order is the buy or the sell or the stop order = self.Transactions.GetOrderById(event.OrderId) self.Log("{0}: {1}: {2}".format(self.Time, order.Type, event)) ## BUY ORDER FILLED ## if event.OrderId == self.buyTicket.OrderId: self.Debug("Buy ticket event detected") # If buy order is filled, create stop loss if self.buyTicket.Status == OrderStatus.Filled: self.Debug("Buy order filled") quantity = self.buyTicket.Quantity # limit price is set below the trigger to maximise the chances of catching a price decrease trigger = (1 - self.initial_stop_percent_delta) * self.buyTicket.AverageFillPrice limit = trigger * 0.99 self.stopTicket = self.StopLimitOrder(self.symbol, -quantity, stopPrice=trigger, limitPrice=limit) self.previousTrigger = trigger self.buyTicket = None ## SELL ORDER FILLED ## elif event.OrderId == self.sellTicket.OrderId: self.Debug("Sell ticket event detected") # If sell order is filled, cancel stop loss if self.sellTicket.Status == OrderStatus.Filled: self.Debug("Sell order filled") self.stopTicket.Cancel() ## STOP ORDER FILLED ## elif event.OrderId == self.stopTicket.OrderId: self.Debug("Stop ticket event detected") # If stop order is filled, cancel the sell order, if any: if self.stopTicket.Status == OrderStatus.Filled: self.Debug("Stop order filled") self.stopTicket = None if self.sellTicket is not None: self.sellTicket.Cancel() self.sellTicket = None

What should I do for this code block to be executed?

Thank uou. Cordially, Benjamin.

Author