Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get daily highs and lows

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

    Get daily highs and lows

    What is the easiest way to get historic daily highs and lows?

    or to be more specific: How can I get the daily highs and lows of yesterday, 2 days before, etc within a strategy script where I use range bars ?
    Last edited by rafe0304; 06-15-2016, 02:29 AM.

    #2
    Hello rafe0304,

    Thanks for your post.

    One way to get the high and low of the previous days would be the use of the GetDayBar() method that will create daily bars from your data and make the OHLC values available.

    Syntax:
    Bars.GetDayBar(int tradingDaysBack).High
    Bars.GetDayBar(int tradingDaysBack).Low

    Please see: http://ninjatrader.com/support/helpG...?getdaybar.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      I cannot even get the High of one day before, since Bars.GetDayBar(1) is null. How can I increase the lookback period?
      Last edited by rafe0304; 06-16-2016, 10:30 AM.

      Comment


        #4
        Hello rafe0304,

        Thanks for your post.

        Using the GetDayBar would require that you have the data loaded before trying to access it. Keep in mind that it makes up a day bar from your exiting data bars. So if you are looking back 1 day you would need 1 day plus the current days data loaded before accessing. You can accomplish this by doing a CurrentBar check (which could be lengthy in this application) or test for null bars first and then access when not null.

        Example:
        if ( Bars.GetDayBar(1) != null)
        {
        yesterdaysHigh = Bars.GetDayBar(1).High;
        }
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Thanks for your answer. Checking for null pointers is an integral part of a defensive programming style.

          But how can I make shure that I got enough data loaded when testing and running my strategy?

          Comment


            #6
            Hello rafe0304,

            Thanks for your reply.

            "So if you are looking back 1 day you would need 1 day plus the current days data loaded before accessing. You can accomplish this by doing a CurrentBar check".

            Reference: http://ninjatrader.com/support/helpG...currentbar.htm
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Can I do that check based on days? If I work with range bars, I got a changing number of bars each day such that I cannot convert the number of days I need in a number of bars.

              So how can I load the necessary number of historic days when I need it in my strategy?

              Comment


                #8
                Hello rafe0304,

                Thanks for your reply.

                Next option would be to add daily bars to your strategy.

                Please see: http://ninjatrader.com/support/helpGuides/nt7/?add3.htm

                and

                http://ninjatrader.com/support/helpG...nstruments.htm
                Paul H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by wzgy0920, 04-20-2024, 06:09 PM
                2 responses
                26 views
                0 likes
                Last Post wzgy0920  
                Started by wzgy0920, 02-22-2024, 01:11 AM
                5 responses
                32 views
                0 likes
                Last Post wzgy0920  
                Started by wzgy0920, Yesterday, 09:53 PM
                2 responses
                49 views
                0 likes
                Last Post wzgy0920  
                Started by Kensonprib, 04-28-2021, 10:11 AM
                5 responses
                192 views
                0 likes
                Last Post Hasadafa  
                Started by GussJ, 03-04-2020, 03:11 PM
                11 responses
                3,234 views
                0 likes
                Last Post xiinteractive  
                Working...
                X