Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using Chartbars.FromIndex

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

    Using Chartbars.FromIndex

    While Using

    for (int barIndex = ChartBars.FromIndex; barIndex <= ChartBars.ToIndex; barIndex++)

    To render a small square on top of all the bars in visible portion of the screen bars, I also get the same exact bars rendered in a different location if I scroll back.

    Why would this be happening?

    #2
    Hello r3n3v,

    If you scroll without adjusting the scale you should see the same number of bars being rendered. The FromIndex and ToIndex are the currently visible bars. To access data from the visible bars you need to use GetValueAt with the index in the loop.

    The example here shows getting the high of each visible bar in the loop, as you scroll you would have the same number of bars and different highs https://ninjatrader.com/support/help...tsub=fromindex

    Comment


      #3
      Ok Thanks makes sense! So how would we adjust the scale ?
      Last edited by r3n3v; 06-29-2023, 12:02 PM.

      Comment


        #4
        Hello r3n3v,

        By adjust the scale I mean if you use the mouse to drag on the X scale that will include or exclude bars. The FromIndex and ToIndex are the indexes of the bars currently scaled into the chart. If you had a chart where 50 bars are visible your loop would cover 50 bars. If you later dragged the scale so 100 bars are visible your loop now works over 100 bars. If you drag the chart to the left or right the amount of bars should generally stay the same so the loop continues to loop that amount of bars however the indexes change.

        Comment


          #5
          Ok I understand that now. Thanks. What I'm wondering is how would we go about int leaving the drawn squares only on the viewable screen and not have it duplicate when I scroll? Hope my question makes sense.

          Comment


            #6
            Hello r3n3v,

            What are your squares based off of?

            Nothing is left on the screen or duplicated when you scroll, each time you scroll the OnRender is re run for the new set of bars. Your logic needs to recalculate the squares based on the visible data.

            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