• 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

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, 10: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 ralett, Today, 11:28 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post ralett
                  by ralett
                   
                  Started by ChazJ, Today, 09:59 AM
                  1 response
                  5 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by Irukandji, Today, 09:34 AM
                  1 response
                  4 views
                  0 likes
                  Last Post NinjaTrader_PatrickG  
                  Started by lunardiplomacy, Today, 08:32 AM
                  3 responses
                  13 views
                  0 likes
                  Last Post NinjaTrader_PatrickG  
                  Started by ralett, Today, 08:24 AM
                  1 response
                  11 views
                  0 likes
                  Last Post NinjaTrader_PatrickG  
                  Working...
                  X