Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

When OnRender is called ?

Collapse
X
 
  • 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.

    #2
    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

    Comment


      #3
      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.

      Comment


        #4
        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,

        When overridden in a derived class, participates in rendering operations that are directed by the layout system. The rendering instructions for this element are not used directly when this method is invoked, and are instead preserved for later asynchronous use by layout and drawing.


        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

        Comment


          #5
          Tulanch,

          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

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by yertle, Today, 08:38 AM
          5 responses
          13 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by frankthearm, Today, 09:08 AM
          2 responses
          4 views
          0 likes
          Last Post frankthearm  
          Started by adeelshahzad, Today, 03:54 AM
          3 responses
          16 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by bill2023, Yesterday, 08:51 AM
          6 responses
          27 views
          0 likes
          Last Post NinjaTrader_Erick  
          Started by NinjaTrader_ChelseaB, 01-08-2017, 06:59 PM
          80 responses
          19,667 views
          5 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X