Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Discretionary adding of a secondary time frame

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

    Discretionary adding of a secondary time frame

    Hi,

    I want to add a second time frame to my strategy. Say my primary time frame is 9 Range bars. I would like to backtest my entries on a shorter "time frame". For example 1 minute bars, or 2 Range bars.

    How can I tell send parameters to my strategy program from the input window to add a Range period type with a 2 value, or a Minute period type and a 1 Minute value so it generates the correct Add() intruction?

    In the case of the 1 Minute period type:
    Add(PeriodType.Minute, 1);

    Or in the case of the 2 Range period type:
    Add(PeriodType.Range, 2);

    I want the Minute, or Range to be a parameter such as: myPeriodType, and the value as myPeriodValue: Add(myPeriodType, myPeriodValue);

    I haven`t been able to do it via variables or conditional statements because the Add() line goes in the Initialize() method and it's giving me a hard time.

    Thank you.

    #2
    rperez, have you already tried setting this period value up as a user defined input parameter for the strategy?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      rperez, have you already tried setting this period value up as a user defined input parameter for the strategy?
      Thanks Bernard,

      I tried to enter the parameters in order to fill the instruction: Add(PeriodType.myPeriodType, myPeriodValue);

      But the compiler generates an error message. Perhaps my user defined parameters are incorrectly defined:

      [Description("")]
      [Category("Data series")]
      public int MyPeriodValue
      {
      get { return myPeriodValue; }
      set { myPeriodValue= Math.Max(1, value); }
      }
      [Description("")]
      [Category("Data series")]
      public string MyPeriodType
      {
      get { return myPeriodType; }
      set { myPeriodType = value; }
      }
      Last edited by rperez; 11-16-2009, 11:00 AM. Reason: Incorrectly written

      Comment


        #4
        rperez, the second is not a string but of type PeriodType, just check what Intellisense expects for the Add() method as parameters.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Bertrand,

          I changed the parameter settings to:

          Variables:
          private PeriodType myPeriodType = "PeriodType.Range";

          Parameters:
          [Description("")]
          [Category("Data series")]
          public PeriodType MyPeriodType
          {
          get { return myPeriodType; }
          set { myPeriodType = value; }
          }

          Stilll get a compiler error.

          Comment


            #6
            Originally posted by rperez View Post
            Bertrand,

            I changed the parameter settings to:

            Variables:
            private PeriodType myPeriodType = "PeriodType.Range";

            Parameters:
            [Description("")]
            [Category("Data series")]
            public PeriodType MyPeriodType
            {
            get { return myPeriodType; }
            set { myPeriodType = value; }
            }

            Stilll get a compiler error.

            I fixed it by changing the variable from:
            private PeriodType myPeriodType = "PeriodType.Range";


            to:
            private PeriodType myPeriodType = PeriodType.Range;

            Everything is working fine now.

            Thank you.

            Comment


              #7
              Bernard,

              Another related question:

              How can I conditionally add the line: "Add(myPeriodType, myPeriodValue);" to my strategy program depending on wether I wish to include a secondary TimeFrame or not.

              The Initialize method does not allow conditional statements such as:

              if (conditionToAddTimeFrame ==true)
              {
              Add(myPeriodType, myPeriodValue);
              }

              Comment


                #8
                rperez, correct for this reason I would suggest you create two strategies, one with intrabar fill simulation and one without. Thanks
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Thanks Bertrand..... I shall do that.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by ScottWalsh, Today, 04:52 PM
                  0 responses
                  1 view
                  0 likes
                  Last Post ScottWalsh  
                  Started by ScottWalsh, Today, 04:29 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post ScottWalsh  
                  Started by rtwave, 04-12-2024, 09:30 AM
                  2 responses
                  22 views
                  0 likes
                  Last Post rtwave
                  by rtwave
                   
                  Started by tsantospinto, 04-12-2024, 07:04 PM
                  5 responses
                  70 views
                  0 likes
                  Last Post tsantospinto  
                  Started by cre8able, Today, 03:20 PM
                  0 responses
                  7 views
                  0 likes
                  Last Post cre8able  
                  Working...
                  X