• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Double entry/exit in multi instrument strategy

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

    Double entry/exit in multi instrument strategy

    Hi,

    I have a working strategy using multiple instruments, however, I seem to have gotten a problem with it. When I attach a SetProfitTarget(), the strategy will post a double entry and exit every time it hits the profit target on the same bar. If I set the profit target high enough for it to not get hit at all then the strategy will run as normal. If I set it to a single tick then I will get a double entry and exit on every signal that triggers it.

    This problem seems to only happen when I use a multi instrument strategy, it doesn't happen on a single instrument strategy.

    Anyone have any ideas on how I can fix this problem?

    #2
    Hello Stoop,

    Thank you for your post.

    Can you post screenshots of the difference with the double entries and the single entry that you are seeing?

    To send a screenshot press Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file.

    For detailed instructions please visit the following link

    http://take-a-screenshot.org/
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Hi Cal,

      Thanks for your reply, I have attached a screenshot of two entries, one with the profit target hit and one without it hitting the profit target.
      It's run on the NQ and ES instruments.
      Attached Files

      Comment


        #4
        Hello Stoop,

        Thank you for your response.

        Can you provide the code used that produces the double entry?
        Patrick H.NinjaTrader Customer Service

        Comment


          #5
          Hi PatrickH,

          I created an example code that is producing the same results:

          Code:
          #region Using declarations
          using System;
          using System.ComponentModel;
          using System.Diagnostics;
          using System.Drawing;
          using System.Drawing.Drawing2D;
          using System.Xml.Serialization;
          using NinjaTrader.Cbi;
          using NinjaTrader.Data;
          using NinjaTrader.Indicator;
          using NinjaTrader.Gui.Chart;
          using NinjaTrader.Strategy;
          #endregion
          
          // This namespace holds all strategies and is required. Do not change it.
          namespace NinjaTrader.Strategy
          {
             /// <summary>
             /// </summary>
             [Description("")]
             public class example : Strategy
             {
                 #region Variables
          
          // User defined variables (add any user defined variables below)
                 #endregion
          
                 /// <summary>
                 /// This method is used to configure the strategy and is called once before any strategy method is called.
                 /// </summary>
                 protected override void Initialize()
          {	
          
          	CalculateOnBarClose = false;
          
          	TraceOrders      = true;
          	Add("ES 06-14", PeriodType.Day, 1);
          	SetProfitTarget(CalculationMode.Ticks, 15);
          }
          
          
                 /// <summary>
                 /// Called on each bar update event (incoming tick)
                 /// </summary>
                 protected override void OnBarUpdate()
                 {
          
                    if ((Closes[1][0] - 10) > Opens[1][0]){EnterLong(0,1,"");}
          
                    if (Closes[1][0] < Opens[1][0]){ExitLong(0,"","");}
          		
                 } // OnBarUpdate
          
             }
          }

          Comment


            #6
            Hello Stoop,

            Thank you for your patience.

            Please add a BarsInProgress check for 1 in your code to prevent the entries twice due to the OnBarUpdate() being called twice (once for ES and once for NQ):
            Code:
            			if(BarsInProgress == 1)
            			{
            			if ((Closes[1][0] - 10) > Opens[1][0]){EnterLong(0,1,"");}
            			if (Closes[1][0] < Opens[1][0]){ExitLong(0,"","");}
            			}
            Patrick H.NinjaTrader Customer Service

            Comment


              #7
              That made it work, thank you very much! Really great support you guys have here.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by fredfred, Today, 03:41 AM
              2 responses
              6 views
              0 likes
              Last Post fredfred  
              Started by TraderYoda, Today, 03:33 AM
              0 responses
              0 views
              0 likes
              Last Post TraderYoda  
              Started by pjsmith, Today, 02:56 AM
              0 responses
              2 views
              0 likes
              Last Post pjsmith
              by pjsmith
               
              Started by ntbone, Yesterday, 08:10 PM
              0 responses
              9 views
              0 likes
              Last Post ntbone
              by ntbone
               
              Started by chrislou, 08-28-2015, 03:27 AM
              14 responses
              2,882 views
              0 likes
              Last Post nkhoi
              by nkhoi
               
              Working...
              X