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 funk10101, Today, 09:43 PM
      0 responses
      6 views
      0 likes
      Last Post funk10101  
      Started by pkefal, 04-11-2024, 07:39 AM
      11 responses
      37 views
      0 likes
      Last Post jeronymite  
      Started by bill2023, Yesterday, 08:51 AM
      8 responses
      44 views
      0 likes
      Last Post bill2023  
      Started by yertle, Today, 08:38 AM
      6 responses
      26 views
      0 likes
      Last Post ryjoga
      by ryjoga
       
      Started by algospoke, Yesterday, 06:40 PM
      2 responses
      24 views
      0 likes
      Last Post algospoke  
      Working...
      X