Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

High/Low of previous days

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

    High/Low of previous days

    How can I get high/low of several previous days in my strategy?
    Tried to add day period in initialization:
    Code:
    Add(PeriodType.Day,1);
    and then use
    Code:
    Print(Highs[1][N]);
    where N is day number. But got error in case if N > 0 despite of having several days loaded on minute chart.

    #2
    Welcome to our forums Mathers, which error would you exactly get here?

    You likely miss a CurrentBars check for both your series like shown here - https://www.ninjatrader.com/support/...urrentbars.htm

    Comment


      #3
      The error is:
      You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

      Seems that only one day is loaded to daily series. How can I force this to load more data?

      Comment


        #4
        This will be determined by your primary series load settings you have from the DataSeries window, just load up more days here so the bars required would be fulfilled for both series and OnBarUpdate() called as expected then.

        Comment


          #5
          I already have 10 days set there. But still unable to get even second in my strategy.

          Comment


            #6
            Yes, BarsRequired per default is 20 for your script, so you would need at least 20 daily business days available. So either further load data or lower the BarsRequired setting in your case.

            Comment


              #7
              Thank you, it works now.
              Isn't it possible to set "Days To Load" parameter for chart automatically from strategy?
              I suppose answer is No, so then may be I can define Min Bars Required param from code to avoid changing it manually on each run?

              Comment


                #8
                Great, you could only set a higher default for example for the minute bars type you're working on, just right click in the DataSeries properties to do that.

                Alternatively you can also set BarsRequired from the strategy Initialize() as well.

                Comment


                  #9
                  Thank you again. My last question: Are there any easy way to search not only for high/low but also for local extremums during day?

                  Comment


                    #10
                    What would you exactly look for? Like the hourly highs and lows?

                    Comment


                      #11
                      For High/low in the period of time (not fixed period). I am not sure how to describe it programmable. Something like attached image.

                      Comment


                        #12
                        There would be several ways, one to capture the high and low in a defined time range of bars - http://www.ninjatrader.com/support/f...ead.php?t=8600

                        Another one would be our Swing and Zigzag studies that work by defining a certain swing strength (bars surrounding) for the pivot value or a swing size in points / percent.

                        Comment


                          #13
                          Thanks again Zigzag looks good enough.

                          Comment


                            #14
                            Originally posted by Mathers View Post
                            I already have 10 days set there. But still unable to get even second in my strategy.
                            Have you included the CurrentBars check? 10 days of 10 minute bars should be more than enough, one should think.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                            0 responses
                            580 views
                            0 likes
                            Last Post Geovanny Suaza  
                            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                            0 responses
                            335 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by Mindset, 02-09-2026, 11:44 AM
                            0 responses
                            102 views
                            0 likes
                            Last Post Mindset
                            by Mindset
                             
                            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                            0 responses
                            554 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by RFrosty, 01-28-2026, 06:49 PM
                            0 responses
                            552 views
                            1 like
                            Last Post RFrosty
                            by RFrosty
                             
                            Working...
                            X