Hello good day. I am creating a logic for a bot. And use stop buy and stop sell orders. But there are times when due to volatility ... those requests are not fulfilled. How could you tell the bot that when the order rejected message comes out. He enters the market. I really appreciate your help. Thank you.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Rejected Order
Collapse
X
-
Rejected Order
Hello good day. I am creating a logic for a bot. And use stop buy and stop sell orders. But there are times when due to volatility ... those requests are not fulfilled. How could you tell the bot that when the order rejected message comes out. He enters the market. I really appreciate your help. Thank you.Last edited by tabi5; 05-20-2021, 03:39 PM.Tags: None
-
Hi tabi, thanks for posting.
You can set the strategy's RealtimeErrorHandling to RealtimeErrorHandling.IgnoreAllErrors and handle the reject in OnOrderUpdate. There is an example of doing so in the link.
Best regards,
-ChrisL
-
Thank you very much ... you are the best ninja warrior hehehe ... Your advice worked great. Now I need the bot to enter the market, what would be the way that ninja calls the error that ninja derives from a buy or sell stop order ... so I can tell it after this error occurs, (X) you enter the market. .. // EnterLongStopMarket // EnterLong // EnterShortStopMarket // EnterShort
Comment
-
Hello tabi5,
Thanks for your reply.
In post #2 Chris provided a link to the help guide. In the help guide, it shows an example of the code needed to trap a rejected order. From there you can place your next order.
From the help guide:
Code:protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity , int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError) { // Assign stopLossOrder 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 if (order.Name == "myStopLoss" && orderState == OrderState.Filled) stopLossOrder = order; if (stopLossOrder != null && stopLossOrder == or der) { // Rejection handling if (order.OrderState == OrderState.Rejected) { // Stop loss order was rejected !!!! [B]// Do something about it here[/B] } } }
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, 03-13-2026, 05:17 AM
|
0 responses
87 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
151 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
80 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
53 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
62 views
0 likes
|
Last Post
|

Comment