Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

cant catch rejected orders from NINJATRADER BROKER

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

    cant catch rejected orders from NINJATRADER BROKER

    my strategy issues EnterShortStopMarket orders. however, there are times that the parket is so fast that the actual price bypasses the order stop price.
    obviously the order is rejected. I need to catch the rejection and issue a market order with whatever price I can get in order to not miss the move at all, even with unfavorable entry price.

    though I have coded the bellow structure, I still get rejection and it doesn't work.
    Can anyone advice what am i doing wrong?

    Code:
    if (State == State.SetDefaults)
    {​
         RealtimeErrorHandling = RealtimeErrorHandling.StopCancelCloseIgnoreRejects;
    }
    
    
    protected override void OnBarUpdate()
    {
       entryOrder=EnterLongStopMarket(1,entryprice,"Entry");
    }
    
    
    protected override void OnOrderUpdate(Cbi.Order order, double limitPrice, double stopPrice,int quantity, int filled, double averageFillPrice,Cbi.OrderState orderState, DateTime time, Cbi.ErrorCode error, string comment)
    {
        if (order.Name == "Entry")
        {
            entryOrder = order;
        }
    }
    
    
    protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
    {
         if (entryOrder != null && entryOrder == execution.Order && execution.Order.OrderState == OrderState.Rejected )
         {
            if( GetCurrentAsk() > entryprice)
            {
               entryOrder=EnterLong(1,"Entry");
            }
        }
    }

    #2
    Hello dadarara,

    Thank you for your post.

    All order rejection handling should be done from OnOrderUpdate(). It looks like you have the code for your order rejection handling in OnExecutionUpdate().

    The documentation for RealTimeErrorHandling has code demonstrating handling order rejections from OnOrderUpdate():





    Please also make sure that if you have changed the RealTimeErrorHandling in State.SetDefaults that the old strategy instance is removed and a new instance is added in order to load the new defaults.

    Please let us know if you have any further questions.

    Comment


      #3
      oops
      thanks
      changing

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      66 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      141 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      75 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      46 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      51 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X