Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time of the first bar of the chart

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

    Time of the first bar of the chart

    Hello,

    how can I identify the time of the first bar of the current chart?

    Gerik

    #2
    Hello Gerik,

    Thanks for your post and welcome to the Ninjatrader forums!

    Can you clarify what you mean by the first bar of the chart?

    For example do you mean the first bar of the data series of the chart?

    Do you mean the first visible bar on the left side of the chart?

    Do you mean the 1st bar on the right side of the chart?

    Can you elaborate on what you are trying to accomplish?

    Comment


      #3
      Hello NinjaTrader_PaulH!

      Thank you for your answer.

      I mean the first bar of the data series of the chart (the first one on the left side).

      Gerik

      Comment


        #4
        Hello Gerik,

        Thanks for your reply.

        The data series that provides data to the chart generally will have more data than can be shown in the chart.

        So I am assuming you are wanting the leftmost visible bar on the chart.

        There are no documented means to identify this bar. It is possible using undocumented means. In your NinjaTrader are two indicators that may help. Please see CustomPlotSample which is well commented in the code. For an example of processing the bars on the chart, take a look at the "Pivots" indicator, starting at line 481 is an example of "firstBarIndexpainted" which is what you may be looking for.

        Comment


          #5
          Hello PaulH,

          thank you for your reply.

          The indicator CustomPlotSample seems not to be included in my list of indicators within NinjaTrader.

          However, I want only to get the first bar in the data series.

          Gerik

          Comment


            #6
            Hello Gerik,

            Thanks for your reply.

            Just to make sure, you have posted in the NinjaTrader7 forum. The indicator CustomPlotSample is a NinjaTrader7 provided indicator and should be in your system.

            What specific information then are you trying to get from the first bar of the data series?

            Comment


              #7
              Hello Paul,

              I just want to retrieve the datetime of the first bar of the data series.

              I have NinjaTrader 8 (64 Bit).

              Best regards
              Gerik

              Comment


                #8
                Hello Gerik,

                Thanks for your reply.

                When you run a script (Indicator or Strategy) on a chart, the script will load data starting with the first bar of the data series. At the time that bar is loaded you could save the time of that bar. In OnBarUpdate() you could do something like:

                if (CurrentBar == 0) // Current bar is the system bar processing counter and zero is the first bar of the counter
                {
                Print ("First bar starts at: "+Time[0]) // or you could save the date time into a variable DateTime type for use later.
                }


                References:



                Comment


                  #9
                  Hello Paul,

                  thank you for your reply.

                  Can I directly access the first element of the time series with Time[Time.Length-1] ?

                  Gerik

                  Comment


                    #10
                    Hello Gerik,

                    Thanks for your reply.

                    You can access the first data point with Time[CurrentBar].

                    CurrentBar is the bar counter: reference: https://ninjatrader.com/support/help...currentbar.htm

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    578 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    334 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    101 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    553 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    551 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X