Fix NT8 Order Quantity Mismatch
Budget: $10 – $30 USD
My unmanaged strategy on NinjaTrader 8 Desktop occasionally submits profit-target or stop-loss orders whose quantities do not equal the live position size. In fast or partially filled market conditions I may be long 4 contracts while the submitted TP is for 6, or the stop is set for 3. The result is orphaned orders, exposure I never intended, and an ever-growing tangle of rejected modifications.
I have already refactored the logic several times—resetting internal order objects, double-checking OnExecution and OnOrderUpdate sequencing, and re-querying Account.Get(AccountItem.PositionQuantity) after each fill—yet the mismatch keeps resurfacing. I clearly need a deeper diagnostic and a clean, reliable fix.
What I need from you is:
• Root-cause analysis explaining why execution, position tracking, and internal state become unsynchronised under rapid or partial fills.
• Corrected code (or a well-documented patch) that guarantees exit order quantities always mirror the current position.
• A repeatable test or simulation showing the solution working in high-velocity/partial-fill scenarios.
• A concise hand-off note so I can maintain or extend the solution confidently.
Acceptance criteria:
• After the fix, every time a new TP/SL pair is queued, their quantities exactly equal the open position size at that moment.
• No orphaned or over-sized exit orders can be produced, even when fills arrive out of order or in multiple parts.
• Solution remains fully compatible with NinjaTrader 8 Desktop unmanaged order handling.
• All code compiles cleanly and is free of new warnings or errors.
If this sounds straightforward to you and you have proven experience with NT8 unmanaged strategies, your help will let me trade again without babysitting the DOM.
I have already refactored the logic several times—resetting internal order objects, double-checking OnExecution and OnOrderUpdate sequencing, and re-querying Account.Get(AccountItem.PositionQuantity) after each fill—yet the mismatch keeps resurfacing. I clearly need a deeper diagnostic and a clean, reliable fix.
What I need from you is:
• Root-cause analysis explaining why execution, position tracking, and internal state become unsynchronised under rapid or partial fills.
• Corrected code (or a well-documented patch) that guarantees exit order quantities always mirror the current position.
• A repeatable test or simulation showing the solution working in high-velocity/partial-fill scenarios.
• A concise hand-off note so I can maintain or extend the solution confidently.
Acceptance criteria:
• After the fix, every time a new TP/SL pair is queued, their quantities exactly equal the open position size at that moment.
• No orphaned or over-sized exit orders can be produced, even when fills arrive out of order or in multiple parts.
• Solution remains fully compatible with NinjaTrader 8 Desktop unmanaged order handling.
• All code compiles cleanly and is free of new warnings or errors.
If this sounds straightforward to you and you have proven experience with NT8 unmanaged strategies, your help will let me trade again without babysitting the DOM.