Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Performance issues with Draw.Text in an indicator

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

    Performance issues with Draw.Text in an indicator

    Hi,

    I'd like to draw a text for every bar.

    This looks like:

    In the method OnBarUpdate:
    Draw.Text(this,"Volume" + CurrentBar,myVolume.ToString(),1,High[1]);

    If I run this on a tick chart I get severe performance problems with NinjaTrader.

    Is there any possibility to solve this performance problem? I tried it with MaximimumBarsLookBack = 256, but that didn't help.

    Thanks in advance,

    erkees

    #2
    Hello erkees,

    Unfortunately, if you plan to draw on every bar this will take a large amount of resources to draw this many objects.

    You would need to limit the number of objects drawn.

    You could use a counter to draw a certain number of objects.
    Code:
    private int counter = 0;
    
    if (counter < 255)
    {
     ++counter;
    }
    else 
    {
    counter = 0;
    }
    Draw.Text(this,"Volume" + counter,myVolume.ToString(),1,High[1]);

    After the counter resets, it will begin moving the bars and will only have 256 on the chart at any given time.

    However, this will still require that the drawing be drawn and moved as the historical data processes.

    You could also limit the amount of drawings in historical data.
    Code:
    if (CurrentBar < BarsRequiredToPlot || (State == State.Historical && CurrentBar < Math.Max(1, Count - 256)))
    return;
    This would stop the script from processing if there are not enough bars to plot or if there are more than more than 256 bars and current bar is not within the last 256 bars.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      thanks for your answer - that should solve the problem.

      Thanks,

      erkees

      Comment

      Latest Posts

      Collapse

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