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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      47 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      23 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      33 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      51 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      42 views
      0 likes
      Last Post CarlTrading  
      Working...
      X