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.
    JesseNinjaTrader Customer Service

    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.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by geotrades1, Today, 10:02 AM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by ender_wiggum, Today, 09:50 AM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by rajendrasubedi2023, Today, 09:50 AM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by bmartz, Today, 09:30 AM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by geddyisodin, Today, 05:20 AM
        3 responses
        26 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X