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 kinfxhk, 07-14-2026, 09:39 AM
      0 responses
      10 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-13-2026, 10:18 AM
      0 responses
      59 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-13-2026, 09:50 AM
      0 responses
      41 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-13-2026, 07:21 AM
      0 responses
      47 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-11-2026, 02:11 AM
      0 responses
      38 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Working...
      X