Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Forcing a Specific Number of Viewable Bars on a Chart

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

    Forcing a Specific Number of Viewable Bars on a Chart

    Hello,

    Is it possible or allowed to set a number of bars viewable on a chart? For example, if the user sets the value to 100 and tries to increase the number of viewable bars on the chart, the indicator will automatically resize the chart so there are fewer visible bars.

    Thanks
    Unsuitable
    NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

    #2
    Hello Unsuitable,

    Thanks for your post.

    There is not any supported means to programmatically adjust what is visible on the chart, as this is intended to be set by the user. There not any unsupported hints I could offer as well.

    Something to consider would be to use OnRender to detect when the number of bars visible (ChartBars.ToIndex - ChartBars.FromIndex) are outside of what you expect and to draw a message with Draw.TextLayout advising the user their should adjust their chart.

    To get more acquainted with SharpDX rendering, please see the Help Guide article below, and please see the SampleCustomRender indicator that comes with NinjaTrader.
    https://ninjatrader.com/support/help..._rendering.htm

    We look forward to assisting.

    Comment


      #3
      Hello Jim,

      Yeah, that's what I figured and I'm using the method mentioned above. Thanks anyway!
      Unsuitable
      NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

      Comment


        #4
        Hello Jim,

        So currently the number (the number of bars on screen) only updates when F5 is hit or there's a tick update. Is there a method in which the script detects if the user moves the chart around?

        Thanks
        Unsuitable
        NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

        Comment


          #5
          Hello Unsuitable,

          This would all be done from OnRender which gets called with every render pass on the chart. If the user modifies the chart, OnRender will be called.

          I am not having an issue printing the difference of ChartBars.FromIndex and ChartBars.ToIndex when I do so in OnRender, and I have attached a gif showing my test.

          Click image for larger version

Name:	image_65814.gif
Views:	212
Size:	143.7 KB
ID:	1149816

          Let us know if there is anything else we can do to help.

          Comment


            #6
            Nevermind, had the calculations the in OnBarUpdate method instead of the in OnRender method.
            Unsuitable
            NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

            Comment

            Latest Posts

            Collapse

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