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 NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          62 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          134 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          75 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          45 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          50 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X