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

How to get daily OHLC info from intraday bar

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

    How to get daily OHLC info from intraday bar

    At the first bar of a new session(5min chart), I would like to read the OHLC information (daily) of the previous 5 days.

    Can I use Bars.GetDayBar(1).High (for the high of the previous day)
    Bars.GetDayBar(2).High (for the high of two days ago)
    Bars.GetDayBar(3).High (for the high of three days ago)
    ...

    Similarly for other daily data.

    Thanks

    #2
    Hello mandm,

    Thanks for your post and welcome to the forums!

    Yes, the GetDayBar method will provide that data based on the 5 minute chart data and session template employed. Reference: http://ninjatrader.com/support/helpG...?getdaybar.htm

    You will also want to perform a check to ensure that you have enough data loaded before accessing the GetDayBar method, keep in mind you are creating day bars from the charts 5 minute bars.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Paul View Post
      Hello mandm,

      Thanks for your post and welcome to the forums!

      Yes, the GetDayBar method will provide that data based on the 5 minute chart data and session template employed. Reference: http://ninjatrader.com/support/helpG...?getdaybar.htm

      You will also want to perform a check to ensure that you have enough data loaded before accessing the GetDayBar method, keep in mind you are creating day bars from the charts 5 minute bars.
      Does this mean BarsArray[1] is referencing the day bars?

      Comment


        #4
        Hello,

        Thanks for your post.

        The Bars.GetDayBars() method would only work with the charts data series (BarsArray[0]).
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Paul View Post
          Hello mandm,

          Thanks for your post and welcome to the forums!

          Yes, the GetDayBar method will provide that data based on the 5 minute chart data and session template employed. Reference: http://ninjatrader.com/support/helpG...?getdaybar.htm

          You will also want to perform a check to ensure that you have enough data loaded before accessing the GetDayBar method, keep in mind you are creating day bars from the charts 5 minute bars.
          What is the proper way to perform a check to ensure there is enough data loaded?

          Comment


            #6
            Hello,

            Thanks for your post.

            You must check for a null reference since null is returned if there is insufficient intraday data to build a trading day bar.

            Example from the helpguide:

            if (Bars.GetDayBar(1) != null)
            Print("The prior trading day's close is: " + Bars.GetDayBar(1).Close.ToString());

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

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by bortz, 11-06-2023, 08:04 AM
            47 responses
            1,603 views
            0 likes
            Last Post aligator  
            Started by jaybedreamin, Today, 05:56 PM
            0 responses
            8 views
            0 likes
            Last Post jaybedreamin  
            Started by DJ888, 04-16-2024, 06:09 PM
            6 responses
            18 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by Jon17, Today, 04:33 PM
            0 responses
            4 views
            0 likes
            Last Post Jon17
            by Jon17
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            12 views
            0 likes
            Last Post Javierw.ok  
            Working...
            X