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 geddyisodin, 04-25-2024, 05:20 AM
        8 responses
        58 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by halgo_boulder, 04-20-2024, 08:44 AM
        2 responses
        21 views
        0 likes
        Last Post halgo_boulder  
        Started by mishhh, 05-25-2010, 08:54 AM
        19 responses
        6,189 views
        0 likes
        Last Post rene69851  
        Started by gwenael, Today, 09:29 AM
        0 responses
        5 views
        0 likes
        Last Post gwenael
        by gwenael
         
        Started by Karado58, 11-26-2012, 02:57 PM
        8 responses
        14,830 views
        0 likes
        Last Post Option Whisperer  
        Working...
        X