Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnOrderUpdate never called when order rejected

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

    OnOrderUpdate never called when order rejected

    Hello,

    i set RealtimeErrorHandling = RealtimeErrorHandling.IgnoreAllErrors,
    but OnOrderUpdate never called.

    Code:
    #region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.Indicators;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion
    
    //This namespace holds Strategies in this folder and is required. Do not change it. 
    namespace NinjaTrader.NinjaScript.Strategies
    {
    	public class Reject : Strategy
    	{
    		protected override void OnStateChange()
    		{
    			if (State == State.SetDefaults)
    			{
    				Description = @"Reject";
    				Name = "Reject";
    				RealtimeErrorHandling = RealtimeErrorHandling.IgnoreAllErrors;
    				IsUnmanaged = true;			
    			}
    			else if (State == State.Configure)
    			{
    				RealtimeErrorHandling = RealtimeErrorHandling.IgnoreAllErrors;
    				IsUnmanaged = true;
    			}
    		}
    
    		protected override void OnBarUpdate() 
    		{ 
    			if (Position.MarketPosition == MarketPosition.Flat 
    				&& Time[0].Year == 2010 && Time[0].Month == 5 && Time[0].Day == 27 
    				&& Time[0].Hour == 10 && Time[0].Minute == 0)
    			{		
    				Order orderSL = this.SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.StopMarket, 1, 0, Close[0] - 40 * TickSize, "ORDER", "ORDER");				
    				int i = 0;	
    			}
    		}
    		 
    		protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError)
    		{ 
    	          // Rejection handling 
    	          if (order.OrderState == OrderState.Rejected) 
    	          {
    	               // Stop loss order was rejected !!!! 
                           Print("Never called ... :-(");
    	          } 
    		}
    	}
    }

    #2
    Hello,

    Thank you for the question,

    I tried the script provided but I do see the print: "Never called ... :-(" happening which indicates the override is being called.

    I wanted to check, are you getting a Popup message about the rejection when the print is not occuring? if not this is likely that the order was not rejected.

    If you are, have you tried completely removing all instances of the strategy from the Control center Strategies tab followed by re enabling the strategy?

    Additionally, if you are using an older version of the beta, have you tried this in the most recent beta 6?


    I look forward to being of further assistance.

    Comment


      #3
      Hello!

      I wanted to check, are you getting a Popup message about the rejection when the print is not occuring?
      NO

      If you are, have you tried completely removing all instances of the strategy from the Control center Strategies tab followed by re enabling the strategy?
      YES

      Additionally, if you are using an older version of the beta, have you tried this in the most recent beta 6?
      YES

      OnOrderUpdate never called.

      In log have showed this message:
      Code:
      Disabling NinjaScript strategy 'Reject/57302553'
      Strategy 'Reject/57302553': A Buy order placed at '5/27/2010 10:00:00 AM' has been ignored since the stop price is less than or equal to the close price of the current bar. This is an invalid order and subsequent orders may also be ignored. Please fix your strategy.
      Enabling NinjaScript strategy 'Reject/57302553' : On starting a real-time strategy - StartBehavior=WaitUntilFlat EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=Per entry execution ErrorHandling=Ignore all errors ExitOnSessionClose=True / triggering 30 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On bar close IsUnmanaged=True MaxRestarts=4 in 5 minutes
      Attached Files

      Comment


        #4
        Hello,

        I wanted to gather more details on this. Currently I have not been able to re produce what you are but only see the expected result of this being called.

        I wanted to ask, being that you are using a past date, are you using this in a backtest or checking this specifically for historical bars?

        Can you remove the time check you are doing and run this in live data to see if you get the expected result?

        Can you provide further details on where this is being used in the platform and the settings being used?

        I look forward to being of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        672 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        379 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        111 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        575 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        582 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X