Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Orders missed using foreach(Order order in account.Orders)
Collapse
X
-
Hello TIA,
Are you printing the execution.ToString() at the top of OnExecutionUpdate() without any conditions?
To confirm, you are waiting for the order to fill and have an execution, is this correct?
If you are wanting to see the order become working before it fills, print the order.ToString() from OnOrderUpdate().
Chelsea B.NinjaTrader Customer Service
-
Hello defa0009,
Looping through a collection while it is being modified will typically cause an error and disable the script.
I recommend looping over the <Account>.Orders.ToList() to copy the list first to avoid errors.
Once the loop starts, it will not contain any new elements and you would have to loop through again.
However, if you are looking for new orders or updated orders, this would update in the <Account>.OrderUpdate event.
Chelsea B.NinjaTrader Customer Service
Comment
-
Hello defa0009,
Looping through the account orders would not be correct.
The strategy is only able to see orders that are submitted by the strategy. Orders submitted to the account will update update OnExecutionUpdate() as they would not be orders made by the strategy.
If you want to handle orders submitted to the account, you would need to add event handlers to the account.
Chelsea B.NinjaTrader Customer Service
Comment
-
Hello defa0009,
I think understand. You've named your custom event handler OnExecutionUpdate() and this is not the same as the NinjaScript Strategy OnExecutionUpdate() override method. Apologies for the confusion.
<Account>.ExecutionUpdate runs when the execution is processed, <Account>.OrderUpdate runs when the order is processed, the <Account>.Orders collection updates after the order is processed.
Try moving that code to the OrderUpdate event.
Chelsea B.NinjaTrader Customer Service
Comment
-
Hello defa0009,
"OnExecutionUpdate() occurs after OnOrderUpdate() completes"
This is not always the case and should not be relied upon.
Execution objects should be accessed from the <Account>.ExecutionUpdate event. Order objects should be accessed from the <Account>.OrderUpdate event.
What example are you referring to?
Chelsea B.NinjaTrader Customer Service
Comment
-
Hello defa0009,
<Account>.ExecutionUpdate runs when the execution is processed, <Account>.OrderUpdate runs when the order is processed, the <Account>.Orders collection updates after the order is processed.
Try moving that code to the <Account>.OrderUpdate event.Chelsea B.NinjaTrader Customer Service
Comment
-
Hello defa0009,
When the execution event occurs, the stop and target have not been submitted.
Once these are submitted and become active in the <Account>.OrderUpdate() event these will show as accepted and / or working.
No, from the <Account>.ExecutionUpdate event of the entry these orders should not yet exist.Chelsea B.NinjaTrader Customer Service
Comment
-
Hello defa0009,
Below is a video showing no orders are being removed from the collection.
Attached is the test script.
AccountOrdersCollectionTest_NT8.zip
The orders are added when they update the <Account>.OrderUpdate event.
The orders remain after they have been added to the collection.
"I need to be able to tell when all OrderUpdate events have completed"
Your previous inquiry was to know how an order has finished it's last update. An order will last update when the order is filled, rejected, or cancelled.
A stop and target will not yet be submitted and become working at the exact time the entry fills. It takes time for those orders to be submitted and become working.
When the stop is created and submitted, it will be available in the <Account>.Orders collection and will update the <Account>.OrderUpdate collection.
Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
557 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
324 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
545 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
547 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment