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

Identifying which entry signal

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

    Identifying which entry signal

    Hey guys is there a way to identify which entry signal has an open position?

    For example for entry signal 1 Position.Quantity>0?

    I now have it set to

    EntryHandling = EntryHandling.UniqueEntries;

    #2
    Hello elitetradernyc,

    Thank you for your post.

    You would need to use IOrder objects for the entry and exit orders and call the FromEntrySignal and Quantity properties of the IOrder object for the exit. For example:
    Code:
            #region Variables		
            IOrder enter;
    		IOrder exit;
            #endregion
    
            
            protected override void Initialize()
            {
               	EntriesPerDirection = 1;
            }
    		
    		protected override void OnBarUpdate()
    		{
    			if(Historical)
    				return;
    			enter = EnterLong(2, "enter");
    			
    			if(exit != null)
    			{
    				Print("Entry " + exit.FromEntrySignal);
    				Print(" is long " + exit.Quantity);
    			}
    		}
    		protected override void OnOrderUpdate(IOrder order)
    		{
    			if(enter != null && enter == order)
    			{
    				if(order.OrderState == OrderState.Filled)
    				{
    					exit = ExitLongStop(Close[0] - 20 * TickSize, "exit", "enter");
    				}
    			}
    		}
    For information on IOrder objects please visit the following link: http://www.ninjatrader.com/support/h...nt7/iorder.htm

    Please let me know if I may be of further assistance.

    Comment


      #3
      Hi Sir, I entered this code just as you suggested but for some reason on the instrument ES the stops do not always activate even though the price goes way below the stop level, can you help me determine why? Here is the code below exactly as it stands within my test strategy: I ran it on 1 tick betterrenko and 1 minute charts for 2013.

      #region Variables
      // Wizard generated variables
      IOrder enterLong1a;
      IOrder exitLong1a;

      protected override void Initialize()
      {
      CalculateOnBarClose = true;
      EntriesPerDirection = 1;
      }

      protected override void OnBarUpdate()
      {

      if(Bars.BarsSinceSession<2)
      {
      enterLong1a = EnterLong(2, "enterLong1a");
      }

      if(exitLong1a != null)
      {
      Print("Entry " + exitLong1a.FromEntrySignal);
      Print(" is long " + exitLong1a.Quantity);
      }
      }

      protected override void OnOrderUpdate(IOrder order)
      {
      if(enterLong1a != null && enterLong1a == order)
      {
      if(order.OrderState == OrderState.Filled)
      {
      exitLong1a = ExitLongStop(Close[0] - 2 * TickSize, "exitLong1a", "enterLong1a");
      }
      }
      }
      Last edited by elitetradernyc; 11-27-2013, 10:25 AM.

      Comment


        #4
        Hello elitetradernyc,

        Thank you for your response.

        You can use ExitLongStopLimit() to add a limit price to try and catch any break through the stop price. For example NinjaTrader ATM Strategies by default use a Stop Limit order with a 20 tick offset for the limit in order to try to catch any breaks past the stop level.

        For information on ExitLongStopLimit() please visit the following link: http://www.ninjatrader.com/support/h...gstoplimit.htm

        Please let me know if I may be of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by wzgy0920, 04-20-2024, 06:09 PM
        2 responses
        26 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 02-22-2024, 01:11 AM
        5 responses
        32 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, Yesterday, 09:53 PM
        2 responses
        49 views
        0 likes
        Last Post wzgy0920  
        Started by Kensonprib, 04-28-2021, 10:11 AM
        5 responses
        192 views
        0 likes
        Last Post Hasadafa  
        Started by GussJ, 03-04-2020, 03:11 PM
        11 responses
        3,235 views
        0 likes
        Last Post xiinteractive  
        Working...
        X