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!
See more
See less

Partner 728x90

Collapse

Rejected Order

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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.

    #2
    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
    Chris L.NinjaTrader Customer Service

    Comment


      #3


      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


        #4
        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 rocketman7, Today, 01:00 AM
        0 responses
        1 view
        0 likes
        Last Post rocketman7  
        Started by wzgy0920, 04-20-2024, 06:09 PM
        2 responses
        27 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 02-22-2024, 01:11 AM
        5 responses
        32 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 04-23-2024, 09:53 PM
        2 responses
        74 views
        0 likes
        Last Post wzgy0920  
        Started by Kensonprib, 04-28-2021, 10:11 AM
        5 responses
        193 views
        0 likes
        Last Post Hasadafa  
        Working...
        X