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 bortz, 11-06-2023, 08:04 AM
      47 responses
      1,603 views
      0 likes
      Last Post aligator  
      Started by jaybedreamin, Today, 05:56 PM
      0 responses
      8 views
      0 likes
      Last Post jaybedreamin  
      Started by DJ888, 04-16-2024, 06:09 PM
      6 responses
      18 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by Jon17, Today, 04:33 PM
      0 responses
      4 views
      0 likes
      Last Post Jon17
      by Jon17
       
      Started by Javierw.ok, Today, 04:12 PM
      0 responses
      12 views
      0 likes
      Last Post Javierw.ok  
      Working...
      X