• 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

Obtaining the time frame of the chart

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

    Obtaining the time frame of the chart

    I need to be able to do this:

    var=chart time frame for index = 0

    Thank you..
    Duke

    #2
    dukeb,

    You can use the BarsPeriod object to get this information. Please read more here : http://www.ninjatrader.com/support/h...barsperiod.htm
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Adam,
      Thank you...
      Just for clarification, this is only for the base period. It cannot be indexed for other time frames, correct??
      Duke

      Comment


        #4
        duke,

        You can use BarsPeriods for multiple time-frames or instruments : http://www.ninjatrader.com/support/h...arsperiods.htm
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Thank you Adam... that got me where I needed to be.
          Duke

          Comment


            #6
            DukeB,

            Please feel free to contact us any time.
            Adam P.NinjaTrader Customer Service

            Comment


              #7
              OK... I am using
              BPer= BarsPeriod.Value;
              This will give me an integer. 30, 60 etc. This is what I want.

              However a 1 can me a minute or a daily chart.
              I tried using BarsPeriod.Id to determine if this is Daily, Minute, Hrly etc.
              So far no luck.
              Any suggestions?
              Regards,
              Duke

              Comment


                #8
                Originally posted by dukeb View Post
                OK... I am using
                BPer= BarsPeriod.Value;
                This will give me an integer. 30, 60 etc. This is what I want.

                However a 1 can me a minute or a daily chart.
                I tried using BarsPeriod.Id to determine if this is Daily, Minute, Hrly etc.
                So far no luck.
                Any suggestions?
                Regards,
                Duke
                Post your code in question.

                thanks

                Comment


                  #9
                  Please see bold type below--

                  protected override void Initialize()
                  {
                  BPer= BarsPeriod.Value; <<< Returns integer 1, 30, 90 This is good.
                  But a 1 can be 1 day or 1 minute



                  Add(PeriodType.Minute,BPer*2);



                  CalculateOnBarClose = true;

                  }


                  protected override void OnBarUpdate()
                  {

                  // Print (BarsPeriod.Id) ; <<< I thought this would give me 'Daily'
                  'Minute' etc. It woudn't compile. I found nothing
                  in the literature that would help.

                  // }
                  if (CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired)
                  return;
                  // Condition set 1

                  Comment


                    #10
                    Instead try:

                    Print(BarsPeriod.Id.ToString());

                    Comment


                      #11
                      Notice Add(PeriodType.Day,1); Is for the day....However, I only get 'Minute' returned
                      from Print (BarsPeriod.Id.ToString()).

                      protected override void Initialize()
                      {
                      BPer= BarsPeriod.Value;


                      Add(PeriodType.Day,1);



                      CalculateOnBarClose = true;

                      }


                      protected override void OnBarUpdate()
                      {
                      if (BarsInProgress == 1)
                      {

                      Print (BarsPeriod.Id.ToString()) ; <<<< Prints 'Minute
                      Print(BarsPeriods[1].Value); <<<< Prints 1
                      }

                      Comment


                        #12
                        You need to learn more about BarsInProgress and multi-timeframe.

                        Code:
                        Print (BarsPeriods[1].Id.ToString())    ;
                        Originally posted by dukeb View Post
                        Notice Add(PeriodType.Day,1); Is for the day....However, I only get 'Minute' returned
                        from Print (BarsPeriod.Id.ToString()).

                        protected override void Initialize()
                        {
                        BPer= BarsPeriod.Value;


                        Add(PeriodType.Day,1);



                        CalculateOnBarClose = true;

                        }


                        protected override void OnBarUpdate()
                        {
                        if (BarsInProgress == 1)
                        {

                        Print (BarsPeriod.Id.ToString()) ; <<<< Prints 'Minute
                        Print(BarsPeriods[1].Value); <<<< Prints 1
                        }

                        Comment


                          #13
                          Thank you, Sledge...
                          Point taken.
                          I will keep reading and studying.
                          Thanks again,
                          Duke

                          Comment


                            #14
                            Originally posted by dukeb View Post
                            Thank you, Sledge...
                            Point taken.
                            I will keep reading and studying.
                            Thanks again,
                            Duke
                            this might help

                            There are usually 2 things, reference without the plural is for the BarsInProgress = 0, (which can be any of the bars,depending on what the callback is), and the plural of the reference, which requires the [x] and references any of the dataseries explicitly defined.

                            Comment


                              #15
                              Sledge,
                              That really does help. Thank you for taking the time.
                              Duke

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Oracletrades, Yesterday, 02:56 AM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by Bbrandon5567, Today, 04:56 PM
                              1 response
                              3 views
                              0 likes
                              Last Post Bbrandon5567  
                              Started by NeverDownMoney, Today, 11:05 AM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_ChrisL  
                              Started by NeverDownMoney, Today, 12:19 PM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_ChrisL  
                              Started by pstrusi, Today, 04:30 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post pstrusi
                              by pstrusi
                               
                              Working...
                              X