Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get unhandled exception error when attempting to move a chart

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

    Get unhandled exception error when attempting to move a chart

    I'm converting one of my NT7 classes into NT8...I have the class in an indicator, and that indicator appears to run well (it just renders the string "Hello" to the top-left corner of the chart)...but whenever I attempt to move or resize that chart, an unhandled exception is produced.

    I'm not able to trap the error in my indicator or in my class...so I'm looking for your review and analysis.
    Attached Files

    #2
    Does the error look anything like this? I only had this one time.

    Comment


      #3
      I am seeing the same issue consistently using your script -- thank you for reporting this. I will take a closer look at what may be causing the issue, and I'll post back here either with an explanation or an ID number for a report to our development team.
      Dave I.NinjaTrader Product Management

      Comment


        #4
        I believe I see what is causing the issue now, and this may help with sledge's issue, as well. The issue came down to the point at which "renderTarget" was being assigned. I noticed that the issue occurs every time the chart window is "grabbed," whether you are about to move it, resize it, or are simply holding down the mouse button in a way that grabs the chart's edge or the entire window.

        It appears that RenderTarget is the object which is null at that particular moment, so assigning RM.renderTarget = RenderTarget at the moment OnRender is called results in no error when bars are being painted, etc., but causes the error when the chart is preparing to move or be resized. This is because of the way that we handle resizing and moving of the chart. Rather than dynamically painting the chart as it is being moved or resized, we are essentially displaying an image representing the state of the chart at the moment the moving or resizing began, then returning to painting as usual afterwards.

        To resolve the issue, I moved the assignment of RM.renderTarget into OnStateChange() State.Configure. With this change, the text disappears while the chart is being moved or resized, but immediately reappears afterward, because it is always assigned to the RenderTarget of the chart this way.
        Last edited by NinjaTrader_DaveI; 10-13-2015, 09:50 AM.
        Dave I.NinjaTrader Product Management

        Comment


          #5
          Hi Dave,

          Can you send me a copy of the new indicator with your changes?

          I'm attempting to interpret and apply your fix, but the fix not fixing the error.

          Comment


            #6
            You bet. I've added a comment to point out the change that I made. All I needed to do was move the assignment of of RM.renderTarget into OnStateChange() State.Configure.
            Attached Files
            Dave I.NinjaTrader Product Management

            Comment


              #7
              Hi Dave,

              I'm finding that your change hasn't helped solve the problem. Can you take a look at it again?

              Comment


                #8
                Can you please describe exactly what is occurring when you try to resize the chart? Are you receiving any errors in the Log, or any compile errors?
                Dave I.NinjaTrader Product Management

                Comment


                  #9
                  It's a runtime error only...and it occurs when I move the chart that contains the CustomRenderer indicator.

                  Here's a screenshot: http://screencast.com/t/wYwmver7r

                  I've attached the Log contents...it shows there are 3 errors occurring each time I move the chart..
                  Attached Files

                  Comment


                    #10
                    Hello,

                    I tried the sample and too see this is occurring during the charts movement.

                    I started by removing all of the try/catch statements from the script to see if the resize was the actual problem event in which was generating an error, after doing this the script is unable to start at all due to a null reference exception. The try catch seems to have allowed the script beyond the point in error, in this case it actually made debugging this more confusing than just not having them.

                    It appears that where you are setting the RenderTarget combined with where the TextFormat is being defined would be the cause of the error.

                    I have attached a reworked sample that no longer contains the error but still utilizes your custom class. I also have removed the Try/catch's to ensure there are no runtime errors.

                    This also makes use of OnRenderTargetChanged(), during the resize the RenderTarget would be destroyed, this allows for creating objects when the target is changed once again.

                    Please let me know if I may be of further assistance.
                    Attached Files
                    JesseNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by algospoke, Yesterday, 06:40 PM
                    2 responses
                    18 views
                    0 likes
                    Last Post algospoke  
                    Started by ghoul, Today, 06:02 PM
                    3 responses
                    14 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Started by jeronymite, 04-12-2024, 04:26 PM
                    3 responses
                    44 views
                    0 likes
                    Last Post jeronymite  
                    Started by Barry Milan, Yesterday, 10:35 PM
                    7 responses
                    20 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Started by AttiM, 02-14-2024, 05:20 PM
                    10 responses
                    180 views
                    0 likes
                    Last Post jeronymite  
                    Working...
                    X