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
Nicolas Ferrari
Hello Rahul, thank you for your clear response. I decided to change limit orders to market orders and avoid that situation with the limit orders.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!