Hi, I am trying to buy stock using a market order, and then have a stop-loss using a stop market order if the price goes at or below a certain price. As I understand from this post:

https://www.quantconnect.com/forum/discussion/8514/stop-market-order-not-triggered-in-backtest/p1

a MarketOrder() using a positive number of shares followed by a StopMarketOrder() with a negative number of shares and a stop price below the current price, should be used. However, when I implement this in my code it seems to purchase the stock and then immediately sell the stock, despite the current price being above the stop price. Would someone know what the issue is? Thanks.