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

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
    BertrandNinjaTrader Customer Service

    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.
        BertrandNinjaTrader Customer Service

        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.
            BertrandNinjaTrader Customer Service

            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.
                BertrandNinjaTrader Customer Service

                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?
                    BertrandNinjaTrader Customer Service

                    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.
                        BertrandNinjaTrader Customer Service

                        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 junkone, 04-21-2024, 07:17 AM
                            10 responses
                            148 views
                            0 likes
                            Last Post NinjaTrader_BrandonH  
                            Started by tsantospinto, 04-12-2024, 07:04 PM
                            6 responses
                            100 views
                            0 likes
                            Last Post tsantospinto  
                            Started by rocketman7, Today, 02:12 AM
                            5 responses
                            26 views
                            0 likes
                            Last Post NinjaTrader_ChelseaB  
                            Started by ZenCortexReal, Today, 08:54 AM
                            0 responses
                            1 view
                            0 likes
                            Last Post ZenCortexReal  
                            Started by ZenCortexReal, Today, 08:52 AM
                            0 responses
                            0 views
                            0 likes
                            Last Post ZenCortexReal  
                            Working...
                            X