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

  • NinjaTrader_ChelseaB
    replied
    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.

    Leave a comment:


  • Steve L
    replied
    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:	58
Size:	24.7 KB
ID:	1060457

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

    Leave a comment:


  • Steve L
    replied
    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, 03:14 PM.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    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.

    Leave a comment:


  • Steve L
    started a topic Trying to Understand Order Handling Rules

    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:

    https://ninjatrader.com/support/help...naged+approach

    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 &amp;&amp; CurrentBar == 100)
    {
        EnterLongLimit(Close[0] * 0.8);
        EnterLongStopMarket(Close[0] * 1.2);
    }
    I'm using:
    • EntriesPerDirection=10
    • TraceOrders = true

Latest Posts

Collapse

Topics Statistics Last Post
Started by traderhawk, Today, 05:53 AM
1 response
22 views
0 likes
Last Post NinjaTrader_Jesse  
Started by ezrollin, Yesterday, 11:26 PM
1 response
41 views
0 likes
Last Post NinjaTrader_PaulH  
Started by ezrollin, Yesterday, 09:10 PM
1 response
52 views
0 likes
Last Post NinjaTrader_PaulH  
Started by Angus7, Today, 04:31 AM
8 responses
54 views
0 likes
Last Post Angus7
by Angus7
 
Started by aligator, Yesterday, 11:24 PM
0 responses
43 views
0 likes
Last Post aligator  
Working...
X