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 NullPointStrategies, Today, 05:17 AM
        0 responses
        39 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        124 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        64 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        41 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X