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

Strange OnRender() Error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Strange OnRender() Error

    Hi,

    I have run into a strange OnRender() error.
    Time Category Message
    6/7/2018 1:39:54 PM Default Indicator 'XX': Error on calling 'OnRender' method on bar 2794: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
    I have traced this error and it appears that RenderTarget is null in the OnRenderTargetChanged() method. The strange thing for me is that this happens on the very last bar painted on the chart, with Calculate != Calculate.OnBarClose.

    Perhaps this is known and expected. If so, could someone please advise on how to handle this issue? Thank you.

    #2
    Hello Zeos6,

    You do need to check that the RenderTarget is not null in OnRenderTargetChanged().

    This is demonstrated in the examples in the help guide.

    Below is a public link.



    The most common reason this error appears is because brushes are not being re-created in the OnRenderTargetChanged().

    Are you able to reduce the code to find which line is causing the error?

    What line of code is causing the error?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi ChelseaB,

      The line that fails is
      Code:
      RenderTarget.DrawGeometry(myPathGeometry, myBrushDX, myStrokeWidth, myStroke.StrokeStyle);
      I have checked immediately before this line and all the parameters are not null. For some reason, that line, RenderTarget.DrawGeometry(), calls OnRenderTargetChanged(), and it is inside OnRenderTargetChanged() that RenderTarget is null. This now means I cannot recreate DX brushes using the NT DX extension methods.

      It occurs on the last historical bar painted on the chart, and the bar is not complete - Calculate !=Calculate.OnBarClose.

      Comment


        #4
        Hello Zeos6,

        I used DrawGeometry in the JtRealStats indicator and this is working on my end without any issue.


        Are you getting the same message when testing this script?


        Can you reduce the code down to just the DrawGeometry code with anything necessary to support that line, export, and post this so I may test your script and review the code?

        (Meaning keep the geometry, brush, int variable, and stroke, and continue re-creating the brush in onrendertargetchanged, but remove everything else)
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thank you for your help ChelseaB.
          I have figured out the issue. It turned out I had made my media dictionary static and was instantiating a second, non-static, dictionary with the values from the static dictionary. Removing the static modifier solved the issue. I will now address the way the dictionaries are being created and used.

          Comment


            #6
            Folks I am having similar problems with 'OnRender ()':
            2018-12-31 15:44:39:124|3|16|Failed to call OnRender() for chart object 'Region': 'Object reference not set to an instance of an object.'
            2018-12-31 15:46:08:787|3|16|Chart rendering failed. There is likely a problem with a chart object's OnRender method. D2D error = 'HRESULT: [0x88990001], Module: [SharpDX.Direct2D1], ApiCode: [D2DERR_WRONG_STATE/WrongState], Message: The object was not in the correct state to process the method.
            2019-01-01 21:47:34:759|3|4|Indicator 'noftIES COT Distribution V2': Error on calling 'OnRender' method on bar 3217026: Index was outside the bounds of the array.
            2019-01-01 23:04:14:000|3|16|Failed to call OnRender() for chart object 'Region': 'Object reference not set to an instance of an object.'
            2019-01-02 12:24:32:507|3|16|Chart rendering failed. There is likely a problem with a chart object's OnRender method. D2D error = 'HRESULT: [0x88990001], Module: [SharpDX.Direct2D1], ApiCode: [D2DERR_WRONG_STATE/WrongState], Message: The object was not in the correct state to process the method.
            '
            2019-01-02 12:24:32:507|3|16|Chart rendering failed. There is likely a problem with a chart object's OnRender method. D2D error = 'HRESULT: [0x88990001], Module: [SharpDX.Direct2D1], ApiCode: [D2DERR_WRONG_STATE/WrongState], Message: The object was not in the correct state to process the method.
            '
            2019-01-02 12:24:32:507|3|16|Chart rendering failed. There is likely a problem with a chart object's OnRender method. D2D error = 'HRESULT: [0x88990001], Module: [SharpDX.Direct2D1], ApiCode: [D2DERR_WRONG_STATE/WrongState], Message: The object was not in the correct state to process the method.
            '
            2019-01-02 13:53:02:508|3|16|Failed to call OnRender() for chart object 'Region': 'Object reference not set to an instance of an object.'
            2019-01-02 14:08:35:092|3|4|Indicator 'MurreyMath': Error on calling 'OnRender' method on bar 1311: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

            Comment


              #7
              Hello rutariq,

              Welcome to the NinjaTrader support forum.

              It looks like these errors are a little different from what the original author had posted about, I do see some indicators mentioned in your error messages:

              noftIES COT Distribution V2
              MurreyMath
              When you see this error, is this when you do something specific such as apply the mentioned indicators or load a workspace with these items included in it? Have you at this point tried an empty chart/workspace with either of the mentioned indicators to see if that also has the same error?

              I also noted we are in the NinjaScript development forum, just to confirm are you developing a NinjaScript item and then seeing these errors, or is this a general error/ general platform use question?

              This is very likely not related to the original post, once I have more details surrounding your specific situation I may additionally move this post to its own thread.



              I look forward to being of further assistance.
              JesseNinjaTrader Customer Service

              Comment


                #8
                I have been having nt8 crashes as well and seem to have a similar error. What other memory could it be referencing?

                2019-01-24 12:16:07:273|3|4|Indicator '': Error on calling 'OnRender' method on bar 3: Attempted to read or write protected memory. This is often an indication that other memory is corrupt

                Comment


                  #9
                  Hello stifland,

                  Are you currently developing an indicator and seeing this error? This is the NinjaScript development forum so if you are developing something we would need additional details such as the specific syntax which controls the error for you.

                  If you are otherwise just seeing this error when using an item, please create a new thread in the Technical Support forum or email our platform support [at] ninjatrader.com directly.

                  The error you are reporting relates to a specific indicator, however, this error alone is not enough information to say what may be happening. You would likely need to test to find which specific indicator is throwing the error by reducing the workspace, and then debug the code of the script at that point to see why that is happening based on its use.

                  The error omits the indicators name, this would be due to how the item was programmed along with removing the indicators Label when you apply it. To find the specific indicator, you can add Labels to the indicators you have applied in the chart, and the next time the error occurs it should instead report the indicators name instead of "".

                  I look forward to being of further assistance.



                  JesseNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by AttiM, 02-14-2024, 05:20 PM
                  12 responses
                  213 views
                  0 likes
                  Last Post DrakeiJosh  
                  Started by cre8able, 02-11-2023, 05:43 PM
                  3 responses
                  237 views
                  0 likes
                  Last Post rhubear
                  by rhubear
                   
                  Started by frslvr, 04-11-2024, 07:26 AM
                  8 responses
                  117 views
                  1 like
                  Last Post NinjaTrader_BrandonH  
                  Started by stafe, 04-15-2024, 08:34 PM
                  10 responses
                  47 views
                  0 likes
                  Last Post stafe
                  by stafe
                   
                  Started by rocketman7, Today, 09:41 AM
                  3 responses
                  12 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Working...
                  X