Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Reset BarsToLoad in code.

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

    Reset BarsToLoad in code.

    I use an indicator that plots numerous moving averages and text objects directly on the chart. It works well if the number of bars does not grow too large... which causes me to lose access to certain windows, like Data Series and Indicators.

    If I have a high frequency of bars, ie low barsPeriod, I have to frequently reset Bars To Load in the Data Series window to keep the number of bars that have been drawn low enough to prevent overload.

    I want to automate the reset of BarsToLoad when the number of bars exceeds a set amount. I tried: if(CurrentBar > this.BarsToLoad + 100) {this.BarsToLoad = OriginalNumberOfBarsLoaded} (OriginalNumberOfBarsLoaded is my variable used in State.Configure to capture that value.)

    But that attempt to reset BarsToLoad in code has no affect. Would there be a way to reset BarsToLoad in code, or any other way to automate resetting that?​

    #2
    Hello c2injacator,

    There are not any ways to modify the dataseries from NinjaScript, that has to be configured in the UI.

    The only option here would be to make the code more efficient. The first step would be to find out which part is causing the slowdown, it may be the text objects if you are drawing text on every bar. In that case OnRender could be used instead to make it only draw the text on the visible bars which would be more efficient. That removes the object so less memory/resources are spent on the drawing objects that are no longer being used.

    Comment


      #3
      If you don't want to get into OnRender, you can remove historical draw objects. Whenever you draw a new object, remove one N bars back and you will only have N objects.
      eDanny
      NinjaTrader Ecosystem Vendor - Integrity Traders

      Comment

      Latest Posts

      Collapse

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