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 futtrader, 04-21-2024, 01:50 AM
                4 responses
                41 views
                0 likes
                Last Post futtrader  
                Started by Option Whisperer, Today, 09:55 AM
                1 response
                11 views
                0 likes
                Last Post bltdavid  
                Started by port119, Today, 02:43 PM
                0 responses
                7 views
                0 likes
                Last Post port119
                by port119
                 
                Started by Philippe56140, Today, 02:35 PM
                0 responses
                7 views
                0 likes
                Last Post Philippe56140  
                Started by 00nevest, Today, 02:27 PM
                0 responses
                7 views
                0 likes
                Last Post 00nevest  
                Working...
                X