Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 daniel_weber8, Today, 01:21 PM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_ChristopherS  
      Started by jungsoohuh, Today, 12:07 PM
      1 response
      25 views
      0 likes
      Last Post NinjaTrader_PaulH  
      Started by SharonSS, Today, 11:54 AM
      1 response
      17 views
      0 likes
      Last Post NinjaTrader_Jim  
      Started by crystalet, Today, 11:20 AM
      3 responses
      22 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by SuperDude123, Today, 09:23 AM
      1 response
      34 views
      0 likes
      Last Post NinjaTrader_JustinD  
      Working...
      X