In a strategy using Managed Approach I wrote, I do get sometimes an overfill due to following situation:
A long position is open, with a limit target set as an exit order. It may happen that the limit price level is very close to the price level where an opposite entry signal occurs. The limit Exit order apparently gets into conflict with the automatic closing of the Long Position due to the EnterShort() method being called around the same time triggered by the short entry Signal.
I have two options to tackle this:
1. I do not use limit Exit orders anymore, but do a Close Exit order when Price reaches or exceeds the target. As I am in control of this based on a tick stream, I can control the time from triggering the Exit order until it is executed (filled), and for that time span not allow the opposite entry, but set a flag for the request of the opposite entry and process it once that the Close has been fully filled.
I am pretty sure to get this stable and robust, just a matter of Setting a flag for the Close out order processing and a flag for a pending entry request.
2. Keeping the limit order (which would be cool since I can manually adjust the Price Level in my strategy), I could only think of detecting the OnOrderUpdate() Event that the limit is being processed and act the same way as above, i.e. wait until the limit order is filled, and work with a pending request for the opposite entry in that case.
However, I assume that there is a time of uncertainty stemming from the Server notifiying the Ninja Trader Client program of the limit order being processed in OnOrderUpdate() which makes this approach unusable.
Is this correct or is Option 2 a viable robust way to avoid the overfill?
Thanks for opinions and help from more experienced programmers on this platform.
Cheers,
Martin
Comment