Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ChartBars.ToIndex and Count don't make sense to me

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

    ChartBars.ToIndex and Count don't make sense to me

    I have an indicator that uses multiple series, so maybe this is where I'm confused.

    I have secondary series of 5 second & 1, 2, 3, and 5 minute

    In my example below I am on the 1 min chart.

    For Rendering purposes, I'm trying to match stuff I render on the screen with my right margin. I don't want stuff "pre-rendering" before I see the bar when scrolling through a chart.

    Seems like a pretty simple concept if I know the index of the last bar rendered on the chart, ChartBars.ToIndex, and the index for various things I render, Time[0].

    I know I can get in trouble with the difference between the index that starts on the right side at bar 0, aka Time[0], and the index that starts with the first bar in the series on the left side. But I don't think that is my problem... yet


    When I put this in my indicator
    HTML Code:
    Print(ChartBars.ToIndex + "    " + Count + "     " + CurrentBar);            
    ​
    I get this:
    Click image for larger version

Name:	image.png
Views:	81
Size:	30.6 KB
ID:	1315877

    Sees like the last visible bar on my chart is 2545 when there are only 510 bars on my chart.

    ​When I scroll to the beginning of my chart I get this. The 105 is correct in this case. That is the index of the last bar on the right side of the chart.
    Click image for larger version

Name:	image.png
Views:	45
Size:	28.6 KB
ID:	1315878


    I just want to check and if an object doesn't have a "start index" to the left of ChartBars.ToIndex I won't render it. it will keep me from cheating


    what am I missing?
    ​​

    #2
    Hello cre8able,

    The ChartBars.ToIndex is the last visible bar on the chart, which changes as the chart is scrolled (which I feel you do understand).

    This will be for the primary series only (BarsInProgress 0).

    Are there series added to the script with AddDataSeries()?

    CurrentBar is the bar currently updating OnBarUpdate (for whichever series has a bar update) starting with bar 0, while Count is the total number of bars.

    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      thanks Chelsea

      I need CurrentBar and Count for the primary series. I assume the best way is to create "count" and "currentBar" variables and set the values in OnBarUpdate when I'm processing the primary series.


      is that correct?

      Comment


        #4
        Hello cre8able,

        CurrentBars[0] is the CurrentBar for the primary series, BarsArray[0].Count is the count of the primary series.

        Chelsea B.NinjaTrader Customer Service

        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
        572 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        574 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X