Im looking for some assistance in trying to understand and fix this problem that tends to keep occurring in my strategy :
The issue is that I had an active strategy going short that had 3 contracts, this current position was supposed to exit fully after reaching the set profit target by submitting 3 buy limit orders. Upon doing so I noticed that an extra entry was logged ( 4 buy to cover orders) so instead of my position being flat as it should have, my current market position has changed to long 1 contact.
When reading the log I see that at 1:01 pm there was an order submitted under my signal name "TakeProfits" which consisted of 3 buy to cover limit orders at a specified price. The logs shows the history of that order being submitted, accepted, then worked. Upon working it submitted a change to the limit price, which eventually led to this updated order being accepted and worked. The log then shows that order of 3 being partially filled which leads to the execution message saying 2 contracts were executed ( this is execution49400583169_1) . Next message shows an update to my current position now being 1 contract short still. Then after the update of the position, the log then shows the original; order 49400583169 , getting that final fill of 1 buy to cover limit long which shows as a "execution49400583169_2". Next update shows the position as flat which I have highlighted in the screen shot.
I'm trying to under stand why and how to fix what happens after this, and I think its due to the fact of the order being partially filled at first but im not sure. It submits another buy to cover long entry order under my "TakeProfits" signal name which leaves an open unmanaged position that was not supposed to be executed. Looking at the prints, I can see that the strategy followed all the rules the correct prices, and at the right time, but it keeps opening too many orders. At first I had my "ProfitTake" exit submitting market orders and it was giving me the same issue of too many entries. After some further research of order handling I came across ninja traders "managed approach" which is "Internal Order Handling Rules That Reduce Unwanted Positions". I saw that this managed approach doesn't apply to market orders, so I then changed the exit orders to limit orders, but I still get the same issue of unwanted positions. Please help, thanks
Comment