Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Trying to Understand Order Handling Rules

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

    Trying to Understand Order Handling Rules

    I'm just trying to verify the order handling rules in the managed approach for myself so I know how everything works:

    Here is the relevant section from the NT8 Help Guide:



    The following rules are true per unique signal name:

    Methods that generate orders to enter a position will be ignored if:
    • A position is open and an order submitted by a non market order exit method (ExitLongLimit() for example) is active and the order is used to open a position in the opposite direction
    • A position is open and an order submitted by a set method (SetStopLoss() for example) is active and the order is used to open a position in the opposite direction
    • The strategy position is flat and an order submitted by an enter method (EnterLongLimit() for example) is active and the order is used to open a position in the opposite direction
    • The entry signal name is not unique
    I've verified some of these rules, but I don't understand the part about unique signal names.

    Specifically, in my tests, multiple entries with the same signal name are allowed when it sounds like they shouldn't be.

    What is meant by the bolded item above, "The entry signal name is not unique."?

    In the following I would have expected the 2nd order to be ignored because it has the same signal name, but both orders are accepted.

    I assume I'm not interpreting the rules correctly and would appreciate any clarification.

    Code:
                
    if (Position.MarketPosition == MarketPosition.Flat && CurrentBar == 100)
    {
        EnterLongLimit(Close[0] * 0.8);
        EnterLongStopMarket(Close[0] * 1.2);
    }
    I'm using:
    • EntriesPerDirection=10
    • TraceOrders = true

    Steve L
    NinjaTrader Ecosystem Vendor - Ninja Mastery

    #2
    Hello Steve L,

    The signal name is the name of the order.

    If you named one order "entry1" and another order "entry2", the order handling rules would not conflict for those orders.

    Orders with unique signal names are independent.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks, Chelsea,

      What I'm saying is the opposite: the orders have the same signal name and they do not conflict. Why not?

      The rule says: "Methods that generate orders to enter a position will be ignored if: The entry signal name is not unique."

      If you prefer, we can be more explicit:

      Code:
      if (Position.MarketPosition == MarketPosition.Flat && CurrentBar == 100)
      {
         EnterLongLimit(Close[0] * 0.8, "MyEntry");
         EnterLongStopMarket(Close[0] * 1.2, "MyEntry");
      }
      The trace is summarized as follows:

      Code:
      Strategy 'Order Behavior (Managed)/171212758': Entered internal SubmitOrderManaged() method at 10/31/2018 4:00:00 PM...
      Strategy 'Order Behavior (Managed)/171212758': Entered internal SubmitOrderManaged() method at 10/31/2018 4:00:00 PM...
      Strategy 'Order Behavior (Managed)/171212758': Cancelled expired order...
      Strategy 'Order Behavior (Managed)/171212758': Cancelled expired order...
      If an order were ignored we'd see an entry with "Ignored..." But both orders are accepted. According to the rule, the second order should be ignored because it does not have a unique signal name.
      Last edited by Steve L; 06-11-2019, 04:14 PM.
      Steve L
      NinjaTrader Ecosystem Vendor - Ninja Mastery

      Comment


        #4
        Here's a full strategy example:

        Code:
        //
        // Copyright (C) 2019, NinjaTrader LLC <www.ninjatrader.com>.
        // NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
        //
        
        #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 Using declarations
        
        //This namespace holds strategies in this folder and is required. Do not change it.
        namespace NinjaTrader.NinjaScript.Strategies.Barz.Sandbox
        {
            public class NTGeneralTestStrategy : Strategy
            {
                protected override void OnBarUpdate()
                {
                    if (CurrentBar < BarsRequiredToTrade) { return; }
        
                    if (Position.MarketPosition == MarketPosition.Flat && CurrentBar == 100)
                    {
                        EnterLongLimit(Close[0] * 0.8, "Entry1");
                        EnterLongStopMarket(Close[0] * 1.2, "Entry1");
                    }
        
                }
                protected override void OnStateChange()
                {
                    if (State == State.SetDefaults)
                    {
                        Name = "NT General Test";
                        EntriesPerDirection = 10;
                    }
                    else if (State == State.Configure)
                    {
                        TraceOrders = true;
                    }
                }
        
            }
        }
        The result of running this code on ES daily bars is:

        Click image for larger version

Name:	Capture.PNG
Views:	130
Size:	24.7 KB
ID:	1060457

        You can see that both orders have "Entry1" as their name and nothing is Ignored.

        Steve L
        NinjaTrader Ecosystem Vendor - Ninja Mastery

        Comment


          #5
          Hello Steve L,

          Our development has let me know this is expected behavior and NinjaTrader 7 has the same behavior.

          I've submitted this as a feature request 'orders placed at the same time using the same signal name should also follow the order handling rules' which is being tracked with ID# SFT-4115.

          Please note it is up to the NinjaTrader Development to decide if or when any request will be implemented.
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by DJ888, 04-16-2024, 06:09 PM
          4 responses
          12 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by terofs, Today, 04:18 PM
          0 responses
          7 views
          0 likes
          Last Post terofs
          by terofs
           
          Started by nandhumca, Today, 03:41 PM
          0 responses
          6 views
          0 likes
          Last Post nandhumca  
          Started by The_Sec, Today, 03:37 PM
          0 responses
          3 views
          0 likes
          Last Post The_Sec
          by The_Sec
           
          Started by GwFutures1988, Today, 02:48 PM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Working...
          X