We're running into a particularly maddening issue where NinjaTrader.NinjaScript.AtmStrategy.StartAtmStrate gy fails to attach the ATM strategy to the order in some rare circumstances.
At CrossTrade, we're running a custom NT8 add-on that's serving several thousand users and processing tens of thousands of orders per day. I mention this to give you an idea of the type of size and scale we're working with.
A user can choose to attach an ATM strategy to an order by name, and we process it in an AddOn class as follows:
Order order = myAccount.CreateOrder( instrument, orderAction, ordType, OrderEntry.Automated, tif, quantity, limitPrice, stopPrice, ocoId, strategy != null ? "Entry" : null, Core.Globals.MaxDate, null ); if (order == null) { result["error"] = "Failed to create order"; return result; } if (strategy != null) { NinjaTrader.NinjaScript.AtmStrategy.StartAtmStrategy(strategy, order); } else { myAccount.Submit(new Order[] { order }); }
We cannot reliably reproduce this behavior.
We've verified this is the case because a) if the ATM strategy name is not found, this code will produce an exception, and b) pulling the order history shows a filled execution with name == "Entry", but the owner strategy is null.
So we are certain the ATM strategy exists, the name was entered properly, and we executed NinjaTrader.NinjaScript.AtmStrategy.StartAtmStrate gy(strategy, order) without error. But users report NT8 software enters some kind of state where ATMs fail to attach for an arbitrary amount of time, then suddenly they work again.
We have had users perform test cases with extremely simple ATM strategies, but to no avail. We have narrowed down most general cases where an ATM would fail to attach and documented them here, but none of which solve the problem completely: https://docs.crosstrade.io/webhooks/...roubleshooting
The only sure-fire way to fix the problem is to restart NT8.
NT8 Support Team: I implore you to look into this and not dismiss the issue. There has to be some kind of deep timing issue, threading issue, or race condition in the NT8 internal code.
- Is there anything else we should be aware of when executing StartAtmStrategy from add-on code?
- Are there any other reasons we're not aware of that would cause an ATM attachment failure?
- Is it necessary to marshal those function calls to the primary UI thread?
- What are we missing here?
Thank you for your time and attention.
CrossTrade Team
Comment