Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 algospoke, Yesterday, 06:40 PM
      2 responses
      18 views
      0 likes
      Last Post algospoke  
      Started by ghoul, Today, 06:02 PM
      3 responses
      14 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      44 views
      0 likes
      Last Post jeronymite  
      Started by Barry Milan, Yesterday, 10:35 PM
      7 responses
      20 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by AttiM, 02-14-2024, 05:20 PM
      10 responses
      180 views
      0 likes
      Last Post jeronymite  
      Working...
      X