NinjaTrader 8 – How to reliably link ATM child orders to their originating entry order?

Title: NinjaTrader 8 – How to reliably associate ATM child orders with their originating entry order using StartAtmStrategy()?

Hello NinjaTrader Support Team,

I am developing a custom NinjaScript indicator for NinjaTrader 8 that submits an entry order using Account.CreateOrder() and attaches a selected ATM template using NinjaTrader.NinjaScript.AtmStrategy.StartAtmStrategy().

The ATM template manages two contracts, with two profit targets and two stop-loss orders.

I subscribe to Account.OrderUpdate and can successfully detect the order events, including Target1 being filled and Stop1 being cancelled.

My challenge is identifying exactly which child orders belong to the specific ATM instance initiated by my indicator, without scanning historical account orders or accidentally including orders from other active ATM strategies.

I would appreciate clarification on the following:

  1. Does StartAtmStrategy() expose an ATM instance identifier that can be associated with the originating entry order?

  2. Is there a supported property or API method to retrieve the child orders belonging to that particular ATM instance?

  3. Can the ATM instance, entry order, and its individual target/stop orders be reliably associated using an ATM ID, order references, OrderId, OCO IDs, or another supported mechanism?

  4. What is the recommended approach when multiple ATM strategies may be active on the same instrument and account?

  5. Can this association be maintained safely throughout order-state changes, partial fills, cancellations, and order modifications?

My objective is to create an internal operation identifier and maintain a reliable one-to-one mapping with the ATM’s actual orders throughout the trade lifecycle.

The indicator will only modify the remaining stop-loss order after Target1 has filled and its corresponding Stop1 has been cancelled.

I am using simulated accounts only.

Thank you for your guidance and any relevant documentation or code examples.

Hi Rita,

If you’re starting the ATM from an AddOn or indicator using StartAtmStrategy(), I’d separate tracking the entry order from identifying the ATM-managed stop and target orders.

A few points worth checking:

  1. Keep the original entry Order reference. Account.CreateOrder() provides the Order object, and the order must be named Entry when used with StartAtmStrategy().

  2. Subscribe to Account.OrderUpdate and ExecutionUpdate. These let you observe order-state changes and fills. The entry Order reference can be matched directly, but its OrderId should not be treated as a permanent identifier.

  3. Don’t use timing or OCO alone to associate child orders. OCO identifies cancellation relationships between orders; it doesn’t establish a reliable parent-entry relationship.

  4. Check ATM ownership carefully. Other developers have discussed using Order.GetOwnerStrategy() to inspect the owning ATM instance. However, that method is undocumented, so I’d treat it as an experimental approach rather than a supported production solution.

If you need reliable association across multiple simultaneous ATM instances, I would ask NinjaTrader support whether the AddOn API exposes a supported way to enumerate the orders belonging to a specific ATM instance.

Are you using AtmStrategy.StartAtmStrategy() from an indicator/AddOn, or AtmStrategyCreate() inside a NinjaScript strategy? The available identifiers and monitoring methods differ between those two approaches.

On the StartAtmStrategy path the help guide gives you no ATM id and no documented way from an ATM back to its orders. Taking your five questions in turn:

1. An instance id from StartAtmStrategy. None documented. The StartAtmStrategy page lists two overloads (a template object or a template name, plus the entry Order) and documents no return value, no id and no callback. What you hold is the entry Order you created and passed in. Recognise it with e.Order == entry: the Order page says you can compare Order objects directly, and that OrderId “is NOT a unique value, since it can change throughout an order’s lifetime”. No page promises the ATM submits that same object, so print the comparison once on your build.

2. A supported call for the instance’s child orders. No. The AtmStrategy class page has no member list, and nothing documented on Order points to its ATM. The children arrive on Account.OrderUpdate named Stop1, Target1, Stop2 and Target2, and every ATM from the same template uses those names, so the name alone cannot separate two ATMs. GetAtmStrategyStopTargetOrderStatus and AtmStrategyChangeStopTarget are NinjaScript Strategy methods keyed on the atmStrategyId that strategy passed to AtmStrategyCreate, so an indicator has neither the methods nor the id.

3. What does link them. Only something undocumented: Order has a GetOwnerStrategy() method that returns the owning strategy object, which for an ATM order is the AtmStrategy instance, with a numeric Id. Same owner as your entry, same ATM. One developer on this forum has posted it (a search for GetOwnerStrategy finds the threads), and NinjaTrader has not documented it, so re-check it on each release. On OCO: Stop1 and Target1 should share one e.Order.Oco string and Stop2 and Target2 another, but the guide documents neither the pairing nor uniqueness across ATMs, so treat it as a hint until you have printed it.

4. Several ATMs on one instrument and account. The documented answer is a NinjaScript Strategy. Start each ATM with AtmStrategyCreate and two ids from GetAtmStrategyUniqueId (one for the entry, one for the ATM), map your operation id to the ATM id, read GetAtmStrategyStopTargetOrderStatus("Target1", atmId) and the same for Stop1, then call AtmStrategyChangeStopTarget(0, price, "Stop2", atmId). Each id is one ATM, so they stay apart; it runs in real time only (ATM Strategy Methods). The other documented route keeps the indicator and drops the ATM: on the entry fill, submit Target1 and Stop1 under one OCO string and Target2 and Stop2 under another, both built from your operation id, and the mapping is yours by construction, at the cost of the template’s own features. If you keep StartAtmStrategy, filter by instrument, then by the entry’s owner, then by Name. One limit, from the same developer: entries started while Chart Trader’s ATM selector showed a running instance landed under that instance’s Id with separate brackets, and a Chart Trader Buy Market merges into whichever ATM the selector shows. So use a template nobody trades from Chart Trader, and if two of your entries can overlap, print both Ids before trusting the owner to tell them apart.

5. Across the lifecycle.

  • Partial fills. The GetAtmStrategyStopTargetOrderStatus page notes that entry partial fills a few seconds apart get a stop and a target each, under the same name, so keep a list per name: “Stop2” can be two orders.
  • State changes. Read e.OrderState from the event; the Order object reflects the current state and can already be ahead of it.
  • The modification. Set StopPriceChanged, not StopPrice, and call Account.Change, as the Change page example does; a user here who wrote StopPrice saw the change silently dropped. The confirmation is a later OrderUpdate with Stop2 back in Accepted or Working at the new price, not Change returning. Changing an ATM-owned stop this way is not documented, though users here report it works. Turn off auto breakeven, auto trail and any stop strategy in that template, or the ATM can move Stop2 again after you.
  • Reloads. Reload NinjaScript gives you a fresh indicator instance with empty fields while the ATM keeps running, so keep the owner’s Id outside the instance if you need to pick a running trade back up.
  • Threads. Assume the Account.OrderUpdate handler runs off your chart’s thread, and lock what you share.

If it helps, I can post a small test indicator that starts one ATM and prints every order on the instrument with its owner Id, name, state and OCO string, which shows all of the above on your build in a few minutes.