Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bars array

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

    Bars array

    Hi,
    how to get bars array from certain time (ex. ETH open) to right side of my chart? (what I see). But if I'll go to the right new bars will be added to the array. Until new day (ETH open).

    #2
    Hello Leeroy_Jenkins,

    I am not certain I understand the question how it was written. Are you asking to gather data from only a segment of the chart between the session open and just the last visible bar whatever that may be?

    I look forward to being of further assistance.

    Comment


      #3
      Yes, you're right.

      Comment


        #4
        Hello Leeroy_Jenkins,

        Thank you for that.

        You could do what you are asking however there would be some requirements that surround that. Working with data in that way avoids using BarsAgo and instead would use the actual indexes for the bars. Getting the index of the session bar could be tricky, do you mean the session relative to what you are viewing currently or the most recent session?

        If you mean relative to what is being viewed you would likely need to use IsFirstBarOfSessionByIndex and a loop backwards to find the session that is before the last visible bar on the chart.



        This sample also shows part of what you would need, mainly a loop and the ChartBars.ToIndex. The ToIndex is the last visible bar on the chart and changes as you scroll.


        A loop similar to that could be used, a loop from the ToIndex to 0 checking if the bar by index is a session bar. Once you know the start of the session you can use that index for the start point and the ToIndex as the end point. That would span the session begin to the last visible bar.

        When working with data in this way keep in mind you won't be able to make a series or pass this to indicators, this would be more if you wanted to do some math calculation based on a set of datapoints.

        I look forward to being of further assistance.

        Comment


          #5
          Originally posted by NinjaTrader_Jesse View Post
          Hello Leeroy_Jenkins,

          When working with data in this way keep in mind you won't be able to make a series or pass this to indicators, this would be more if you wanted to do some math calculation based on a set of datapoints.
          I just need to calculate average range of those bars (between ToIndex and first bar of the session) Is this possible?

          Comment


            #6
            I did loop it works great. Now I have index of first bar of session and the last visible bar.

            Comment


              #7
              Hello Leeroy_Jenkins,

              Yes however as noted you would have to just use math and the values from the selected range of datapoints that you find. If you loop over a section of data to gather the values that is no longer a series of data that could have indicators or other existing calculations applied. If you wanted to find the average range of those bars you would have to use logic to calculate that value.

              If you need to find values from the series you have for that section of time you can use the GetValueAt method for series of the script or indicators:


              I look forward to being of further assistance.
              Last edited by NinjaTrader_Jesse; 03-19-2020, 09:55 AM.

              Comment


                #8
                Ok, I got it. Lastly how can I get bar index at specified time?

                Comment


                  #9
                  Hello Leeroy_Jenkins,
                  You can use the following method for that:



                  I look forward to being of further assistance.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  648 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  369 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  108 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  573 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  575 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X