Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Confused
Collapse
X
-
Hello Mindset,
Thanks for your notes.
Yes, that is correct. You could submit protective orders from either OnOrderUpdate() or OnExecutionUpdate().
We recommend submitting protective orders in OnExecutionUpdate() as best practice since this is the fastest possible way to submit protective orders. Further, OnExecutionUpdate() is called after OnOrderUpdate() which ensures your strategy has received the execution which is used for internal signal tracking.
- Likes 1
-
The OnOrderUpdate() method is updated whenever the state of an order changes which allows you to submit and control your stop-loss and profit target orders the instant your entry order is filled.
The OnExecutionUpdate() method is updated whenever you receive an execution or a fill on your orders. This method provides you the fastest possible submission of protective orders. Utilizing the increased granularity provided in these advanced methods can be advantageous to you by providing you with maximum control of how your stop-loss and profit target orders behave.
Sorry to bang on about this but I can submit protective orders in either method? but Execution is fastest but control is better in OnOrderUpdate?
I have not been using OnOrderUpdate - I use ExecutionUpdate instead - but I am starting to think I may be incorrect.
I stumbled across this solely because my OnExecutionUpdate is getting too big and unwieldly. It still works and performs nicely but still if it's not best practice I would rather change.
I should add I Am using the unmanaged approach so it's a little more complex.
Leave a comment:
-
Hello Mindset,
Thanks for your notes.
OnOrderUpdate() is called each time an order managed by a strategy changes state. An order will change state when a change in order quantity, price or state (working to filled) occurs. This is where entry orders should be handled.
From the SampleOnOrderUpdate reference sample: "The entryOrder object allows us to identify that the order that is calling the OnOrderUpdate() method is the entry order. Assign entryOrder in OnOrderUpdate() to ensure the assignment occurs when expected. This is more reliable than assigning Order objects in OnBarUpdate, as the assignment is not guaranteed to be complete if it is referenced immediately after submitting"
OnExecutionUpdate() is an event-driven method that is called on an incoming execution of an order managed by a strategy. An execution is another name for a fill of an order. This method provides you the fastest possible submission of protective orders. Utilizing the increased granularity provided in these advanced methods can be advantageous to you by providing you with maximum control of how your stop-loss and profit target orders behave.
From the SampleOnOrderUpdate reference sample: "We advise monitoring OnExecution to trigger submission of stop/target orders instead of OnOrderUpdate() since OnExecution() is called after OnOrderUpdate() which ensures your strategy has received the execution which is used for internal signal tracking."
Here is a documented reference sample from the help guide demonstrating using OnOrderUpdate() and OnExecutionUpdate() for handling orders: https://ninjatrader.com/support/help...and_onexec.htm
Leave a comment:
-
Confused
I am confused about where I should handle entry orders
Here is an example given in the forum by NT
protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError)
{
// Handle entry orders here. The entryOrder object allows us to identify that the order
//that is calling the OnOrderUpdate() method is the entry order.
// Assign entryOrder in OnOrderUpdate() to ensure the assignment occurs when expected.
// This is more reliable than assigning Order objects in OnBarUpdate, as the assignment is not guaranteed to be complete if it is referenced immediately after submitting
And this in the NT reference examples
protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
{
// Assign entryOrder in OnExecutionUpdate() to ensure the assignment occurs when expected.
// This is more reliable than assigning Order objects in OnBarUpdate, as the assignment is not guaranteed to be complete if it is referenced immediately after submitting
if (execution.Order.Name == "myEntryOrder" && execution.Order.OrderState == OrderState.Filled)
entryOrder = execution.order;
So which is it - or are they interchangeable? Or am I missing something?
thanksTags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Zazzgram91, 04-01-2025, 01:49 PM
|
5 responses
60 views
0 likes
|
Last Post
|
||
Started by pjsmith, 10-01-2019, 08:59 AM
|
26 responses
1,990 views
0 likes
|
Last Post
![]()
by nephew94
Today, 11:32 AM
|
||
Started by Str8boominit, 04-14-2025, 06:03 PM
|
6 responses
80 views
0 likes
|
Last Post
![]()
by Str8boominit
Today, 11:19 AM
|
||
Started by TAJTrades, Today, 09:01 AM
|
5 responses
29 views
0 likes
|
Last Post
|
||
Started by quantyse_ntforum, 03-10-2025, 09:05 AM
|
14 responses
244 views
0 likes
|
Last Post
![]()
by dakensei
Today, 10:50 AM
|
Leave a comment: