Hello, I have the following algo that use Bollinger Band Indicator to trigger buy and sell orders.  The algo send buy and sell orders, and then when one of it is filled, send a stopLoss as also check if condition to take profit is achieved.  

The specific problem that Im facing is that on the backtest, there is a sell order because condition to sell is achieved, and the the algo send a limit order with the stop loss with a price of : stopPrice =  stopPrice = round((self.orderTicketShort.AverageFillPrice * 1.1),2). On this order, the stop price is equal to 150.12 and the entry price is 136.469. But the limit order for the stop loss, is executed and filled at a below price than the stopPrice(at date 2019-07-24 on the attached backtest) that is the price of the limit Order. This price is of 139.05.

 self.lossTicketShort = self.LimitOrder(self.ticker,-quantity,stopPrice,'StopLossShort')
 

So I want to know, why if the limit price for exit with loss is 150.12, the order is executed and filled at the price of 139.05.  This problem take place in the first trade of the backtesting 

 

Thanks in advance for your help

Nicolás

 

Author