Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DX Brushes for drawing heatmap best practice.

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

    DX Brushes for drawing heatmap best practice.

    Hi,

    I have an indicator that draws a heatmap in OnRender. At the moment I am creating a single SharpDX Brush at the beginning of OnRender using a base color, then reassigning it as necessary in a later "for" loop, and disposing of it at the end of OnRender:

    Code:
    				SharpDX.Direct2D1.Brush baseBrushDX = baseColor.ToDxBrush(RenderTarget);
    				
    				for // loop
    				{
    				SharpDX.Direct2D1.SolidColorBrush baseBrushDX  = new SharpDX.Direct2D1.SolidColorBrush(RenderTarget,GetColor(ratio, opacity));
    				//do the drawing
    					
    				}
    				baseBrushDX.Dispose();
    This works fine, but I suspect it's not the best or most efficient way of handling it. Is there a better way?

    Thanks

    #2
    Hello palinuro,

    Thank you for your note.

    Your script looks in line with the SampleCustomRender indicator preloaded on NinjaTrader, where you create a brush, assign and then dispose of it.

    You could also see another example which follows the same format,


    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Could we get a fresh link to this code if available? Thanks.

      Comment


        #4
        Hello mohawkTrader,

        Below is a link to an example of efficiently re-using brushes.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thank you.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          88 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          135 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
          119 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          69 views
          0 likes
          Last Post PaulMohn  
          Working...
          X