would it be possible to force OnOrderUpdate() to be executed always before OnMarketData() and OnBarUpdate()?
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Execution order
Collapse
X
-
Execution order
Hello,
would it be possible to force OnOrderUpdate() to be executed always before OnMarketData() and OnBarUpdate()? -
Hello guillembm,
Thank you for your post.
There is no means to force OnOrderUpdate() to be called before OnMarketData() and OnBarUpdate(). There is no means to force any set of functions to be called in a specific order. Please adhere to the Help Guide on when these functions are called.
Any particular reason you wish to call the functions in this order?
I look forward to your response.
-
I am having rejections when using the ChangeOrder() method. This is because, sometimes, this method is executed and the order has been already filled but the state hasn't been updated.
to prevent it I set these filters before executing ChangeOrder():
if (MyOrder.OrderState != OrderState.Filled
&& MyOrder.OrderState != OrderState.Cancelled
&& MyOrder.OrderState != OrderState.CancelPending
&& MyOrder.OrderState != OrderState.Unknown
&& MyOrder.OrderState != OrderState.ChangePending
&& MyOrder.OrderState != OrderState.Rejected )
but it seems this is not enough. Forcing OnOrderUpdate() to be called first would be a good solution.
Comment
-
Hello guillembm,
Thank you for your response.
So you are calling ChangeOrder() in OnMarketData() and/or OnBarUpdate() but you are calling it when the order state is likely filled, cancelled, or rejected.
Please try updating the an Order object in OnOrderUpdate and then checking that object in the function you call ChangeOrder() in.
Please let me know if you have any questions.
Comment
-
Thanks.
It seems I misunderstood it till now. I always believed that the order state was updated by NT and then this update triggered the execution of OnOrderUpdate() .
When you say "Please try updating the an Order object in OnOrderUpdate and then checking that object in the function you call ChangeOrder() in." it seems like I can force in the order state to be updated. Can you provide sample code?
Comment
-
Hello guillembm,
Thank you for your response.
I mean that you create a custom Order object that you update in OnOrderUpdate() and then call that Order object in any other function.
An example of this is available in the Order object documentation in the Help Guide at the following link: https://ninjatrader.com/support/help...n-us/order.htm
Please let me know if you have any questions.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by wzgy0920, 04-20-2024, 06:09 PM
|
2 responses
27 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:43 PM
|
||
Started by wzgy0920, 02-22-2024, 01:11 AM
|
5 responses
32 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:33 PM
|
||
Started by wzgy0920, 04-23-2024, 09:53 PM
|
2 responses
49 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:29 PM
|
||
Started by Kensonprib, 04-28-2021, 10:11 AM
|
5 responses
193 views
0 likes
|
Last Post
by Hasadafa
Yesterday, 10:19 PM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
11 responses
3,235 views
0 likes
|
Last Post Yesterday, 08:07 PM |
Comment