Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnRender() - freeze for many seconds

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

    OnRender() - freeze for many seconds

    NinjaTrader 8, B11. Windows 10, i7 CPU, 16GB RAM, SSD Drive, 4k resolution monitor.

    When too many objects (rectangles) are drawn, via OnRender(), inside an indicator the horizontal movement on the chart becomes very sluggish. In addition, when the mouse left button is pressed, the chart freezes for many seconds (5 seconds with a 6000-day chart). There is no problem with the right mouse click, upon which, a dialog pops up immediately.

    Attached are the screen image and the indicator zip file for testing.

    1. Is there any way to improve the horizontal scrolling speed after many objects have been drawn on the chart? Which function could be faster than Draw.Rectangle() ?

    2. Is there any way to resolve the screen freeze problem when the mouse left button is pressed?
    Attached Files

    #2
    Hello kkc2015,

    The OnRender method is meant for custom SharpDX rendering and not drawing drawing objects.

    As you scroll the script is redrawing these objects and causing a lot of work.
    Instead, draw these objects once in OnBarUpdate and the drawing object code itself will use OnRender and draw them in the correct places as the chart is moved.

    Also, be sure to re-use brushes instead of recreating them in OnRender. An example of SharpDX rendering and re-using brushes is attached.
    Attached Files
    Last edited by NinjaTrader_ChelseaB; 05-23-2016, 10:24 AM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you very much ChelseaB for the quick response. You have answered my questions completely.
      Your attached sample provide the necessary codes for my indicator implementation.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      571 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      330 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      549 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      549 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X