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
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
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,
-ChrisLChris L.NinjaTrader Customer Service
-
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] } } }
Paul H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by johnMoss, 03-04-2024, 01:53 PM
|
3 responses
47 views
0 likes
|
Last Post
by AndyM
Today, 06:13 PM
|
||
Started by algospoke, Today, 06:01 PM
|
0 responses
8 views
0 likes
|
Last Post
by algospoke
Today, 06:01 PM
|
||
Started by cre8able, Today, 05:53 PM
|
0 responses
9 views
0 likes
|
Last Post
by cre8able
Today, 05:53 PM
|
||
Started by Wessel, 03-23-2024, 02:37 PM
|
3 responses
24 views
0 likes
|
Last Post Today, 04:58 PM | ||
Started by martini, Yesterday, 04:45 PM
|
4 responses
32 views
0 likes
|
Last Post
by martini
Today, 04:48 PM
|
Comment