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

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,

        https://msdn.microsoft.com/en-us/lib....onrender.aspx

        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
          BrettNinjaTrader Product Management

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by aligator, Today, 12:29 PM
          0 responses
          6 views
          0 likes
          Last Post aligator  
          Started by bob77713, Today, 11:30 AM
          0 responses
          0 views
          0 likes
          Last Post bob77713  
          Started by FMtrader, 03-15-2019, 02:30 AM
          6 responses
          38 views
          0 likes
          Last Post James108  
          Started by timko, Today, 08:18 AM
          0 responses
          2 views
          0 likes
          Last Post timko
          by timko
           
          Started by victorsmith, Today, 06:00 AM
          0 responses
          6 views
          0 likes
          Last Post victorsmith  
          Working...
          X