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

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 traderqz, Yesterday, 09:06 AM
                              3 responses
                              20 views
                              0 likes
                              Last Post NinjaTrader_ThomasC  
                              Started by f.saeidi, Today, 10:19 AM
                              1 response
                              4 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by kujista, Today, 06:23 AM
                              5 responses
                              15 views
                              0 likes
                              Last Post kujista
                              by kujista
                               
                              Started by traderqz, Today, 12:06 AM
                              3 responses
                              6 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by RideMe, 04-07-2024, 04:54 PM
                              5 responses
                              28 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Working...
                              X