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

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

    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.

        Paul H.NinjaTrader Customer Service

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

            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:



                Paul H.NinjaTrader Customer Service

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

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by CortexZenUSA, Today, 12:53 AM
                    0 responses
                    1 view
                    0 likes
                    Last Post CortexZenUSA  
                    Started by CortexZenUSA, Today, 12:46 AM
                    0 responses
                    1 view
                    0 likes
                    Last Post CortexZenUSA  
                    Started by usazencortex, Today, 12:43 AM
                    0 responses
                    5 views
                    0 likes
                    Last Post usazencortex  
                    Started by sidlercom80, 10-28-2023, 08:49 AM
                    168 responses
                    2,265 views
                    0 likes
                    Last Post sidlercom80  
                    Started by Barry Milan, Yesterday, 10:35 PM
                    3 responses
                    11 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Working...
                    X