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 judysamnt7, 03-13-2023, 09:11 AM
      4 responses
      59 views
      0 likes
      Last Post DynamicTest  
      Started by ScottWalsh, Today, 06:52 PM
      4 responses
      36 views
      0 likes
      Last Post ScottWalsh  
      Started by olisav57, Today, 07:39 PM
      0 responses
      7 views
      0 likes
      Last Post olisav57  
      Started by trilliantrader, Today, 03:01 PM
      2 responses
      21 views
      0 likes
      Last Post helpwanted  
      Started by cre8able, Today, 07:24 PM
      0 responses
      10 views
      0 likes
      Last Post cre8able  
      Working...
      X