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 alifarahani, Today, 09:40 AM
      3 responses
      15 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by RookieTrader, Today, 09:37 AM
      4 responses
      18 views
      0 likes
      Last Post RookieTrader  
      Started by PaulMohn, Today, 12:36 PM
      0 responses
      5 views
      0 likes
      Last Post PaulMohn  
      Started by love2code2trade, 04-17-2024, 01:45 PM
      4 responses
      40 views
      0 likes
      Last Post love2code2trade  
      Started by junkone, Today, 11:37 AM
      3 responses
      25 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X