I am running into a issue with a strategy that is not firing a market order when I want it to. The code scales out of a position based on a signal ("sorry not going to say what it is") multiple times as the trend develops. The same code fires for each trade except sometimes it just does not fire.
(See attached image)
The system goes short 10 CL ##-## (market replay) and scales out a total of 5 contracts in 3 trades just as I wanted it too. However, the fourth trade to scale out 2 more contracts it does not fire. The bars are painted to show when it should be firing and the text Fire 2 is right next to the exitShort logic to show me that the code is running properly.
Here is the code that has the ExitShort syntax:
if(Position.Quantity > ShortQty) { int newposition = Position.Quantity - ShortQty; //exitShort = ExitShort(newposition); exitShort = ExitShort(newposition,"Buy to Close","Sell to Open"); if(exitShort == null) { DrawText("Qty2","Fire " + newposition,3,Low[0],Color.White) ; } else DrawText("Qty2","Not Null",3,Low[0],Color.White) ; } if(Position.Quantity == 1 && exitShortStop != null && BarsSinceExit() > 1) { exitShort = ExitShort("Buy to Close","Sell to Open"); } }
I can't see any logical reason why Ninjatrader is skipping exit logic, so I need your help to see if someone has ran into this before.
FYI, this is using the Managed approach IOrder with on execution.
Cheers,
Sody
Comment