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:	215
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 CarlTrading, 03-31-2026, 09:41 PM
            1 response
            79 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            40 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            63 views
            2 likes
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            63 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            54 views
            0 likes
            Last Post CarlTrading  
            Working...
            X