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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      87 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      132 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      118 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      67 views
      0 likes
      Last Post PaulMohn  
      Working...
      X