• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.


No announcement yet.

Partner 728x90


When OnRender is called ?

  • Filter
  • Time
  • Show
Clear All
new posts

    When OnRender is called ?

    I am completely lost here.

    I get the following error in the log : Error on calling OnRender method on bar 0 : Object not set to an instance of an object.

    When OnRender() is called ?
    I thought that it was like Plot() in NT7 after all data loaded.

    What do I do if I want to render something on the chart only after all data loaded. I cannot use State == State.Realtime because I want to plot even if the market is closed. I cannot use State == State.DataLoaded because my methods use chartScale and they have to be called from OnRender.

    Hope you understand my problem here. There is something I am missing.

    Hello blar58,

    Thank you for writing in.

    The OnRender() method is called every time the chart values are updated. These updates are driven by incoming data to the chart bars or by a user manually interacting with the chart control or chart scale.

    Based on the error that you have stated here, it may be related to the first item under Implementation changes for Beta 11: http://ninjatrader.com/support/helpG.../?8_0_0_11.htm

    If you are attempting to access any series with a barsAgo value, you should instead use an absolute index lookup through Bars.GetClose(barIndex), or <series>.GetValueAt(barIndex) which are generally more reliable in non-data driven events.

    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service


      can onrenders calls be safely returned from without redraw with no data change?

      to follow up on this... when a chart is first displayed with an indi making use of onrender I notice 3 invocations

      Is it appropriate to perform any updates repeatedly or if possible determine programmically if there are multiple invocations without data change to skip the processing/redraw?

      What I am drawing can be cpu intensive so I am always focused on reducing unnecessary updates.


        NinjaTrader 8 is a WPF application and, as such, methods with names like OnRender are likely implementations of methods such as UIElement.OnRender, documented at the publicly available MSDN documentation here,


        Generally speaking, even if you are an advanced programmer, it is not recommended to attempt to modify these systems internals, as all the underlying code is subject to change by both NinjaTrader and Microsoft. Especially for a commercial product or code shared with other users on the forums, implementing a "kludge" with the existing state of the NinjaTrader WPF implementation would likely cause your code to break at some point in the future. The performance gains rarely outweigh the stability cost.
        Jessica P.NinjaTrader Customer Service



          This is OnRender in an indicator correct? OnRender is already fairly optimized meaning OnRender is called on a 250ms timer on charts and additionally called anytime the visuals are invalidated e.g., resizing the screen or adding and removing indicators for example. I would not return out of OnRender as a first choice of optimization since if you risk your indicator not rendering when it should.

          Instead I would look to make sure my OnRender call is as effecient as possible, this means making sure I'm re-using brushes and declaring them onces with OnRenderTargetChanged and making sure the minimal set of calculations are done only pertaining to rendering in OnRender. https://ninjatrader.com/support/help...getchanged.htm
          BrettNinjaTrader Product Management


          Latest Posts


          Topics Statistics Last Post
          Started by yrch1985, 11-03-2019, 11:49 AM
          8 responses
          Last Post aligator  
          Started by Dr3am, Today, 05:10 PM
          0 responses
          Last Post Dr3am
          by Dr3am
          Started by imalil, Today, 04:28 PM
          0 responses
          Last Post imalil
          by imalil
          Started by bboyle1234, Today, 03:47 PM
          0 responses
          1 view
          Last Post bboyle1234  
          Started by caveat_lector, Today, 03:46 PM
          0 responses
          Last Post caveat_lector