Back

Stop Loss Not Executing

Hi Guys/Gals,

Totally new to quantconnect and using python.  I'm trying to set a stop loss after I enter into a position, but the stop loss order doesn't seem to be firing.  Any pointers?

Update Backtest








Your StopMarketOrder() has been submitted successfully but the order didn't fill. You can add OnOrderEvent() to check the order status

def OnOrderEvent(self, event):
self.Debug(str(event))

As the sell order "StopMarketOrder()" didn't fill before you place the Liquidate() order to sell the holdings, your StopMarketOrder() is canceled and replaced by the Liquidate() sell order.

Please do not save the market price in Initialize() as it is only called once when the algorithm starts. The security price changes in OnData() in each time loop. You should retrieve the price in OnData() with "self.Securities["UPRO"].Price" to determine the stopPrice for the StopMarketOrder.

 
0

Update Backtest





0

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.


Loading...

This discussion is closed