Announcement

Collapse
No announcement yet.

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

    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]
            }
          }
        }

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, 03-13-2026, 05:17 AM
        0 responses
        95 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        153 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        80 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        54 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        70 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X