Using the Managed Methods approach, in Initialize() for my strategy, I'll put:
StopTargetHandling = StopTargetHandling.ByStrategyPosition;
Yes, this is "undocumented", but you can just as well set it in the Strategy Tab when you insert your strategy into the chart, so, whichever way you prefer. Same thing.
What the above does is allow me to add to my position during the course of a trade and have all the contracts entered (I'm trading futures), tagged with the same "fromEntrySignal", ADDED TO ONE STOP AND ONE TARGET so I only have to manage those two other positions during the trade to exit.
For example, in a long position, my initial stop order creation would look like this:
stopOrder = ExitLongStop(0, true, initial_quantity_of_first_entry, stop_price, "Stop", "Long");
and my initial target order creation would look like this:
targetOrder = ExitLongLimit(0, true, initial_quantity_of_first_entry, target_price, "Target", "Long");
For simplicity, let's say all the add-on orders before the stop or target is hit look like simple market orders:
entryOrder = EnterLong(add_quantity, "Long");
Notice above that I'm letting NT know that all these are associated with the "fromEntrySignal".
HERE'S THE PROBLEM:
Let's say I have collected 4 unique positions with the quantity of each position equal to 1 contract.
While the trade is still active, I can move the stop around like this:
ExitLongStop(0, true, Position.Quantity, new_stop_price, "Stop", "Long");
And I can move the target around like this:
ExitLongLimit(0, true, Position.Quantity, new_target_price, "Target", "Long");
What happens when the stop gets hit first?
Perfection! All 4 contracts exit properly. Yippee!
What happens when the target gets hit first?
I only get ONLY ONE CONTRACT EXITED and I'M STILL LONG THREE CONTRACTS! HUH?! No way, I should get an exit of all 4 contracts.
NinjaTrader support, is my reasoning correct? If so, all that's left is for me to prove it to you in code, right? I found someone else talking about this in these forums in 2008. That would make this a 6 yr old huge gaping bug if I'm right. Seriously, I hope I'm missing something because, otherwise, I have to go to the unmanaged world or write extra code to bail on the remaining target contracts with an EXTRA ROUNDTRIP ExitLong("Long") or ExitShort("Short") call and neither of those alternatives is a fun place to be.

Comment