I am trying to figure out how to plot a sell when the stop loss sells the portfolio. It plots the sell when the indicator prompts a sell, but not when the stop loss sells. If I put the StopMarketOrder anywhere else or the "self.Plot("Trade Plot", "Sell", data[self.Firststock].Value)" it just wants to plot useless stuff, Looking to have it plot a sell red triangle either when my indicators sells or the stop loss sells. Couldn't find any documents or previous posts showing how to do this.
Thank you for your help
Alexandre Catarino
Hi Tate Linzel ,
When any order ticket changes its status (submitted, filled, cancel, etc), an order event is generated, and the OnOrderEvent method is called, so it's a good place to call Plot to record the stop market order:
def OnOrderEvent(self, orderEvent): if orderEvent.Status == OrderStatus.Filled: order = self.Transactions.GetOrderById(orderEvent.OrderId) if order.Type == OrderType.StopMarket: self.Plot("Trade Plot", "Sell", orderEvent.StopPrice)
Tate Linzel
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!