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

Error: "Brush series exceeds the maximum number (65535) of unique brushes"

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

    Error: "Brush series exceeds the maximum number (65535) of unique brushes"

    Hi,

    I modified an MACD indicator to paint the panel background in different colors based on conditions. I actually use 2 colors (buy / sell) with different opacities based on a "signal strength".

    When back-testing a strategy using this indicator, I get the following error, if used on a small frequency chart (ex: 30 seconds) on a 2 weeks period:

    "Brush series exceeds the maximum number (65535) of unique brushes. Please adjust code to use fewer brushes."

    The visual consequence is that after a certain amount of time, the back brush color doesn't change anymore, in the Strategy Analyzer chart.

    The way I change the BackBrush in the OnBarUpdate is the following:

    Code:
    Brush b = BuyBackgroundBrush.Clone();
    b.Opacity= buySignalStrengh * OpacityFactor / 100.0;                     
    BackBrush = b;
    BackBrush.Freeze(); // I didn't have the Freeze until now, but it doesn't change anything.
    Opacity Factor = 10 by default.
    BuySignalStrength = 1 to 4, depending on conditions.

    My BuyBackgroundBrush is a property defined as

    Code:
    [XmlIgnore]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Buy Signal Background Color", Order=3, GroupName = "Signal Parameters")]
    public Brush BuyBackgroundBrush
    {get; set;}

    Not sure what I am missing to avoid having so many brushes used by the indicator.

    Thanks for your help.

    #2
    Hello Nagash,

    Thank you for the post.

    This is a normal message if you use too many brushes, the solution would be to just use less brushes.

    For the backtest you could add a user input to disable drawing to avoid the messages. Another alternative is to use OnRender to paint rather than using the individual brush per bar that BarBrush will create. A bool series could be used to store a true/false per bar to know if it should be marked or not and then OnRender could use that data to paint just the current visible bars.

    I look forward to being of further assistance.

    JesseNinjaTrader Customer Service

    Comment


      #3
      I'd suggest creating all the possible Brushes during initialization, and storing them in a List. During the indicator execution you can then select the appropriate Brush according to your indicator logic.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by llanqui, Today, 08:32 AM
      1 response
      5 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by lollers, Yesterday, 03:26 AM
      1 response
      52 views
      0 likes
      Last Post lollers
      by lollers
       
      Started by Salahinho99, 05-05-2024, 04:13 AM
      7 responses
      62 views
      0 likes
      Last Post Salahinho99  
      Started by knighty6508, 05-10-2024, 01:20 AM
      4 responses
      29 views
      0 likes
      Last Post knighty6508  
      Started by OllieFeraher, 05-09-2024, 11:14 AM
      6 responses
      19 views
      0 likes
      Last Post OllieFeraher  
      Working...
      X