Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order Rejected

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

    Order Rejected

    My order is being rejected during market replay I presume because the Market moving so quick.
    So then NT disables and stops running the strategy. I guess what I would like to happen is if this scenario occurs, I would simply like to close the position. How can I accomplish this? What is your advice for this scenario?
    Attached Files

    #2
    Originally posted by reynoldsn View Post
    How can I accomplish this? What is your advice for this scenario?
    See this:


    Code:
     RealtimeErrorHandling = RealtimeErrorHandling.TakeNoAction;
    Then check for OrderState.Rejected in OnOrderUpdate(), and close position if found.

    Unfortunately, the popup message box from NinjaTrader cannot be disabled.

    Comment


      #3
      Your code running in market replay at 1x or 500x follows the same order of events and should work without issue.

      So does it happen in 1x also?

      Post some complete sample code that reproduces the problem and someone might be able to offer a fix/suggestion to your issue. There isn't enough to go on based on your post.

      Comment


        #4
        OK, I would like to implement your suggestion using OnOrderUpdate. Is there a more complete example I can see?

        Comment


          #5
          UPDATE:

          Here is my abbreviated, pertinent code. Does it look like a correct implementation as far as handling order rejection?
          My concern is that now I am using:
          Code:
          RealtimeErrorHandling = RealtimeErrorHandling.TakeNoAction;
          Are there other order problems I now need to manually check?
          Thank you!

          Code:
          private IOrder stopLossOrder = null;
          
          protected override void Initialize()
          {
          	RealtimeErrorHandling = RealtimeErrorHandling.TakeNoAction;
          	
          	SetProfitTarget(sENTRY1L, CalculationMode.Ticks, _profitTarget);
          	SetProfitTarget(sENTRY1S, CalculationMode.Ticks, _profitTarget);
          	SetStopLoss(CalculationMode.Ticks, _stopLoss);
          	
          	//Init order objects
              iOrderL1 = null;
              iOrderS1 = null;	
          
          	EntriesPerDirection = 100;
          	EntryHandling = EntryHandling.AllEntries;
          
          	CalculateOnBarClose = true;
          }
          
          protected override void OnBarUpdate() {
          if (_takeTrade) {
          	EnterShort(1, sENTRY1S);
          	if (stopLossOrder == null) 
          		stopLossOrder = ExitShortStop(Position.AvgPrice + _stopLoss * TickSize); 
          }
          }
          
          protected override void OnOrderUpdate(IOrder order) 
          { 
          	if (stopLossOrder != null && stopLossOrder == order) 
          	{
          		// Rejection handling 
          		if (order.OrderState == OrderState.Rejected) 
          		{
          			// Stop loss order was rejected !!!! 
          			// Do something about it here 
          			Print("Order Rejected at: " + Time[0]);
          		} 
          	}
          }

          Comment


            #6
            Looks like a good start.

            Right after you detect the OrderRejected, say, after your Print,
            exit your position and set your stopLossOrder to null.

            I think RealTimeErrorHandling documentation says this variable
            only deals with order rejected errors.

            Overfill processing, for example, is controlled by a different variable,
            called IgnoreOverFill.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            633 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            364 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            567 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            568 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X