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 Triple_M, Yesterday, 07:48 AM
      8 responses
      46 views
      0 likes
      Last Post Triple_M  
      Started by OllieFeraher, 07-21-2023, 10:01 AM
      5 responses
      71 views
      0 likes
      Last Post EvergreenGain  
      Started by Aundreooper, Today, 01:57 AM
      0 responses
      9 views
      0 likes
      Last Post Aundreooper  
      Started by guardiabldbla, Today, 01:22 AM
      0 responses
      7 views
      0 likes
      Last Post guardiabldbla  
      Started by Ryuujin, Today, 12:32 AM
      3 responses
      35 views
      0 likes
      Last Post Ryuujin
      by Ryuujin
       
      Working...
      X