I am using Managed approach for order submission - Submitting EnterLongLimit order on 15 minute dataseries so that order is cancelled if not filled before the close of the bar on which it was submitted. This is working very well - as expected.
However, along with EnterLongLimit order, strategy is sending Stop Loss and Profit Target OCO orders (Using SetStoploss and SetProfitTarget). The problem lies here - when either of them is partially filled, it gets cancelled sometimes. I suspect it gets cancelled on 15 minute bar close, adopting Entry order behavior. This is obviously not what I am expecting - I want these orders to be active until one or another is fully filled.
Stoploss and ProfitTarget are calculated in State.Configure. It should not make any difference whether they are calculated there, or in OnBarUpdate section, per what I understood from documentation - and I could not figure out any other way to program the behavior in a way that these orders (OCO Stop/Profit) would stay alive until fully filled (ignoring bar close) AND EnterLongLimit order would still cancel at bar close if not filled.
Trace Order says "Cancelled Expired Order" for Stop/Profit order - again, this only happens on partial fills.
I am assuming this also impacts EntriesPerDirection - as soon as partially filled order (stop/profit) is cancelled, program ignores any other orders that should be submitted with message saying that EntriesPerDirection have been exceeded, as there is position still open.
I hope what I tried to explain here is understandable.
Any feedback is greatly appreciated.
Thank you!
Comment