Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

PriorDayOHLC() for other days?

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

    PriorDayOHLC() for other days?


    This is a two part question.

    First, how can I get the OHLC from other days, say, 3, 7, or 10 days ago?

    Second, how can I get the OHLC only from days when the market is open? Say, July 4th falls on a Monday. On Tuesday July 5th, I want to get the prior trading day's OHLC, which would be the previous Friday.

    Thanks again.







    #2
    Hello timmbbo,

    Thanks for your post.

    The PriorDayOHLC indicator returns the prior day (session) open, high, low and close values.

    To get prior day OHLC values for previous days, you would pass in the barsAgo value you want to access. For example, to access the prior day's value you would pass in a barsAgo of 0. To get the value 2 days prior, you would use a barsAgo value of 1, and so on.

    Note that the PriorDayOHLC indicator will get the prior OHLC values of the last trading hours that are not a holiday. For example, if July 4th is a trading hours holiday then the prior day values when the market is open will be returned.

    PriorDayOHLC: https://ninjatrader.com/support/help...r_day_ohlc.htm

    Let me know if I may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      NinjaTrader_BrandonH,

      Doesn't the BarsAgo index depend on the current time frame of the chart? That is, if I have a script running on a 5 minute chart, PriorDayOHLC().PriorLow[0] and PriorDayOHLC().PriorLow[3]​ will return the same value if I'm checking after the 4th or later bar of the same session. Correct?

      If so, when checking for prior days, I need to ensure the BarsAgo index is referencing into the appropriate day. Is there a function available for this?

      Thanks,
      Matt

      Comment


        #4
        Hello Matt,

        Thanks for your note.

        Yes, you are correct. If the primary series is not a daily series it would return the value one bar ago instead of the previous day.

        You could consider checking if IsFirstBarOfSession to identify the first bar of a new session and then use the PriorDayOHLC() value one bar ago to grab the prior day close and save it to a Series<double> variable. When IsFirstBarOfSession is true, this means that the previous bar (one bar ago) was from the previous session.

        IsFirstBarOfSession: https://ninjatrader.com/support/help...rofsession.htm
        PriorDayOHLC(): https://ninjatrader.com/support/helpGuides/nt8/prior_day_ohlc.htm
        Series<double>: https://ninjatrader.com/support/help...t8/seriest.htm

        Please let me know if I may assist further.​
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          Thanks, NinjaTrader_BrandonH!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          63 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          139 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          75 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          45 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          50 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X