Back

Two Stop Market Orders open at the same time like regular Market Orders

1. Every day set two Stop Market Orders, first - $1 above the price, second - $1 below the price, so they shouldn't be filled at the same time, their stop prices are different

2. When one of these orders gets filled, cancel the opposite order and add StopLoss and TakProfit orders

For some days it works as expected, but at some point strategy opens two opposite orders placed at different prices, why?

Logs: only one order should be filled on 2008-01-23, either TM or BM, but not both

Update Backtest








The only thing i have seen in the short time that your orders behave different when leverage is changed to 0.

Cloning your strategy still does not give me your output above. I will check your orders something is suspicious here. hmmm

0

Not sure what was the issue, I guess,  this is some trick of the LEAN, maybe bug, but I managed to fix it by canceling orders by ID, instead of CancelOpendOrders.

In LEAN, when you choose Daily resolution and place 2 orders to close to each other, instead of executing one of them at the current price it fills both and only after this it calls OnOrderEvent, this is why in my strategy it couldn't cancel second daily order because both orders were sent for execution and CancelOpenOrders couldn't find anything. In general it looks like a bug.

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