Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Pointers to using fewer brushes when painting bars

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

    Pointers to using fewer brushes when painting bars

    So running out of brushes when using them to paint bars different colors seems to be a thing. I'm new to brushes and not yet clear on how they work so I'm looking for any guidance on the subject.

    Specifically right now I'm wondering if its possible to say for example paint a hundred bars with a single brush rather than what I imagine is the process right now which may be the source of the problem which is to make a new brush every time a new bar comes along, paint that, get the next bar, make a new brush, and so on.

    Not really clear on the semantics of a "brush". In the real world for example if I had to paint say 5 stools, I'd buy a nice brush at Home Depot and proceed to paint all 5 stools with that one brush. Not sure if/how the semantics carry over into C#. Guessing they do quite nicely and it's just some inefficient coding in the indicator I'm using.

    #2
    Are you talking about brushes in SharpDX or brushes like for BarBrush which are regular WPF brushes?

    If you're talking about in OnRender, see for instance the documentation at: https://ninjatrader.com/support/help...getchanged.htm

    If you mean regular WPF brushes like a SolidColorBrush, you should set up all the brushes you ever might need in advance, such as in State.DataLoaded, and .Freeze() them, then just refer to those from then on.
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Thanks for mentioning these. I don't know what they are yet but I might revisit this thread once I've learnt a bit more. In the meanwhile I've managed to get the script to run through on 2 months of tick data by commenting out the bits in the indicator that used a new brush to color every bar. I'm sure inefficiencies still remain so this solution might not work for larger sets of data.

      Comment


        #4
        Hello markdshark,

        Thanks for your post.

        You could consider creating class-level Brush variables, and assign the Brush color you want the variables in State.SetDefaults.

        //class level variable
        private Brush myBrush1;

        //State.SetDefaults
        myBrush1 = Brushes.DodgerBlue;


        The class-level Brush variables could then be used later in the script such as in OnBarUpdate().

        See this help guide page for detailed information about working with Brushes: https://ninjatrader.com/support/help...th_brushes.htm

        Let me know if I may assist further.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        93 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        138 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        68 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        123 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        73 views
        0 likes
        Last Post PaulMohn  
        Working...
        X