-----------------------------------------------------------
hbMilles,
THe code I added to my strategy to avoid overfilling is disseminated along the strategy. Better than doing this I will explain my solution as a pseudo-code
THe scenario that produced the error was:
- I launch an EnterLongLimit() to open a position.
- On the next bar I launch an ExitLongLimit() order to set a sort of stop profit target.
- If, when launching the ExitLongLimit() order, the EnterLongLimit() wasn't completely filled and a new partial fill came after this point this caused the error.
Following the instructions of the customer service the rule to follow to avoid this problem is to never have two active limit orders competing at the same time.
So, I had to change the code to avoid the EnterLongLimit() and the ExitLongLimit() orders being active at the same time.
The new steps to do the same are:
1- I launch an EnterLongLimit() to open a position.
2- I set two conditions and one of them must be accomplished before launching the ExitLongLimit() order.
-- First condition: the order must be filled. For this I use IOrder handling (http://www.ninjatrader-support.com/H...de.html?IOrder)
-- Second condition: I'm never sure that an order will be completely filled. To solve this I wait a prudential number of bars and then I cancel the EnterLongLimit() order. This code could be useful: http://www.ninjatrader-support.com/H...ml?CancelOrder
3- After one of these conditions are accomplished I cancel EnterLongLimit() order and I can launch the ExitLongLimit() order without creating an overfill issue.
Hope it helps
-----------------------------------------------------------
Comment