Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

A way to identify the Date/Time of the the first and last bar of a chart.

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

    A way to identify the Date/Time of the the first and last bar of a chart.

    But not the rendered part, I mean the entire load of historical bars.
    Thank you
    FVJ

    #2
    Hello efeuvejota01,

    The first bar on the chart is CurrentBar 0 so you could store the time on bar 0 to know the first bar of the dataset. If by the last bar you mean the last of historical that would be Count - 2 while in historical data. It could otherwise be represented as be Time[0], as the script processes the index is incremented 1 at a time and Time[0] would be the most recent bar processed. An example would be On bar 1 the first bar of the chart is CurrentBar 0 and the last bar is CurrentBar 1 because that is all that has been processed up to that point.

    Comment


      #3
      and the question is
      to know the first bar of the dataset
      ?

      Comment


        #4
        Hello efeuvejota01,

        The first bar on the chart is CurrentBar 0 so you could store the time on bar 0 to know the first bar of the dataset.

        Comment


          #5
          The time of the first bar on the chart (of the data series the indicator is attached to) is Times[0][CurrentBars[0]].
          Bruce DeVault
          QuantKey Trading Vendor Services
          NinjaTrader Ecosystem Vendor - QuantKey

          Comment


            #6
            Thank you Bruce!!
            and how do I get the time of the last bar??

            Comment


              #7
              I made some achievements in this regard.
              The following code

              Click image for larger version

Name:	image.png
Views:	359
Size:	15.1 KB
ID:	1258936

              provides the following results... which are ok
              Click image for larger version

Name:	image.png
Views:	326
Size:	4.5 KB
ID:	1258937

              The issue is that I need the ending time at the DataLoaded stage (Line 72 into dhe brackes of the State.DataLoaded), in order to process the indicator during the OnBarUpdate().

              I know the StartTime, I know how many bars are in the chart (Input.Count) but cant´t figure out how to get the final time of the DataLoaded bars.

              I think it is a Syntax issue. any suggestion??
              Thank you very much!!
              FVJ

              Comment


                #8
                Hello FVJ,

                Thank you for your reply.

                Please clarify what you are looking for; are you looking to get the time of the last historical bar on the chart before real-time data starts processing? If so, the last historical bar on the chart may be found with the following:
                Code:
                if (State == State.Historical && CurrentBar == Count - 2)
                {​
                // this action would occur during the last historical bar processed before real-time processing begins
                }
                Otherwise, please provide a more concrete example of what you are looking for. Even a screenshot of a chart highlighting which bar you are referring to might be helpful so we may better understand and assist you.

                We look forward to your reply.

                Comment


                  #9
                  Thank you very much Emily!!
                  FVJ

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  579 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
                  554 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