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

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.
    Brandon H.NinjaTrader Customer Service

    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.​
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Thanks, NinjaTrader_BrandonH!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Vietanhnguyen2hotmailcom, Yesterday, 10:29 AM
          4 responses
          23 views
          0 likes
          Last Post Vietanhnguyen2hotmailcom  
          Started by PhillT, 04-19-2024, 02:16 PM
          4 responses
          35 views
          0 likes
          Last Post PhillT
          by PhillT
           
          Started by ageeholdings, 05-01-2024, 05:22 AM
          5 responses
          37 views
          0 likes
          Last Post ageeholdings  
          Started by reynoldsn, Today, 02:34 PM
          0 responses
          13 views
          0 likes
          Last Post reynoldsn  
          Started by nightstalker, Today, 02:05 PM
          0 responses
          23 views
          0 likes
          Last Post nightstalker  
          Working...
          X