Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unhandled exception

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

    Unhandled exception

    I could see it coming. I had two trade markers on my chart where there should of only been
    one. Next thing you know I am saving a Template for a Line and Unhandled exception and crash. The problem trying to debug this is the Corruption is occurring and it does not necessarily have any relevance to the what you are doing or the indicator you might have been updating. Debugging trying to replicate the issue to focus in on what portion of code is causing it is an illusion. You get repeatable ocurances which have nothing to do with what is causing the corruption and ultimately the problem. I have wasted days doing this.

    See attached picture of Double marker on a single exit. The blue is the entry the magenta arrows are Two exits on the one entry. The second one is an illusion. There is no reversal.

    Jerry
    Attached Files

    #2
    Hello JerryWar, and thank you for your report.

    I will do everything I can to make sure that Ninja is operating correctly underneath your code. Would it be possible to provide us with as much in the way of stack trace and error output messages as exist on your system? Relevant log and trace files can be sent to platformsupport[at]ninjatrader[dot]com , referencing 1611346 and attn:ninjatrader_jessicap .

    With an underlying error message, and if at all possible a simple code sample that produces any unusual behavior, we will be able to determine whether the cause of the behavior is Ninja (and potentially repair Ninja), or whether it will be possible for you to repair this through code.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Jessica
      I see another sign of an issue on another chart.
      It is a precusor of things to come. What I am seeing over and over is that. Custom indicators that have nothing wrong will generate errors when other things go bad. Those things that go bad have no direct error message. I even went so far with an Custom indicator that was giving a problem yesterday that I generated it using the indicator wizard and Still got the problem. Of course the problem was not with the indicator it was Elsewhere.
      See new Indication on a different chart of new problem. There is a little comma where Labels normally appear. All My labels are confirmed blank. But this comma is always a precursor of a crash. I will send the files as requested.

      Jerry
      Attached Files

      Comment


        #4
        As Predicted by the comma.

        016-11-28 10:30:00:569 ERROR: Indicator '': Error on calling 'OnBarUpdate' method on bar 1534: Object reference not set to an instance of an object.

        Jerry

        Comment


          #5
          Thank you for this additional information. This indicates that the cause is in userspace code, since Ninja was able to process correctly until bar 1534. and was able to handle the missing reference condition gracefully, thus indicating Ninja was operating correctly both before and after this occurrence.

          This occurs most often, especially in later bars, in a multi-time frame strategy, or a strategy with custom sub-indicators. As a first step in debugging, I would recommend ensuring your strategy is only operating on the primary data series, and I would recommend commenting out or otherwise disabling execution paths that include sub-indicators. You can then run your code and ensure that there are no errors in this state. From here, you can re-enable each execution path, "short circuiting" so that your first 1533 primary bars are ignored and running over the same data set that produced this message, until you can determine which time series or sub-indicator is causing this behavior.
          Jessica P.NinjaTrader Customer Service

          Comment


            #6
            My Issue is that this ran for two hours before the error. How do you debug that to "ensure" as you put it works i.e. how long do you run it? Do I waste another day ? After spending a full day yesterday debugging on Something that Had no Relationship to the actual error. This has happened multiple times. I have no confidence whatsover that I am really attacking the issue. As I pointed out in my previous post, I saw signs of corruption when the comma appeared. It took some time before the actual error message showed up. This issue I think is much more complex, in that the NinjaScript code is able to Corrupt the environment and then does not provide an accurate error message when good code generates an error. I need better feedback from the environment as I have 8 indicators on the chart I suspect( Which chart actually generated it, I have 5, I am guessing).
            The error message tells me really nothing to point to who or where. If I linked in Debug and Used VS would I get more information? Using it for Breakpoints tell me nothing unless it has the ability to break on the location that generates an error. I understand your thinking, however I have gone down this rabbit hole so many times and keep coming up empty. I need to go about this a different way as repeating the same flawed process is insanity.

            Respectfully
            Jerry

            Comment


              #7
              The information we have available is

              • The bar number this occurred at
              • The instrument, expiries, and time series you were trading when this occurred
              • The exact time this occurred

              If you are able to repeat these three conditions at once, and this occurs again, then we know as you pointed out we need to look at your operating environment. Otherwise, we will know the section of code that we need to look at. Either of these pieces of information will help us debug using Visual Studio.


              An easy way to get at this condition would be to use the market replay connection, so that we are replaying over the exact same information that caused this, and to set up your strategy so that it returns immediately if CurrentBar is less than 1532.


              Once you have set up this test environment, the best way to bring the rest of your code under test will be to set up a breakpoint at the beginning of your OnBarUpdate routine. You may then let your code play until CurrentBar is 1535.


              Should your code have an error that is caught, you will know exactly what to do. In the more likely event (since you mentioned this was running for several hours) that this error condition is not reproduced, you will be able to follow your code's execution path between bars 1532 and 1535 in the same environment that produced an error, and can bring just these parts of your code that were activated under test. You will want to set up several unit tests over just the code that was executed. This way, when this intermittent error occurs again, the exact reason will be captured, and an error will occur on a line of code you control.
              Jessica P.NinjaTrader Customer Service

              Comment


                #8
                Ok, but these are tick bars. They will never generate the same in Playback.
                I will mark the bar after market before loading playback and try but I am doubtful.

                Jerry

                Comment


                  #9
                  To clarify, our goal is not necessarily to cause the same error to occur again. Our goal, instead, is to give you a clear picture of your execution path, so that you may bring your code under test. Should any questions come up once you have a clear view of your execution path surrounding what occurred, as you write unit tests surrounding what occurred, please let us know and we will be happy to help.
                  Jessica P.NinjaTrader Customer Service

                  Comment


                    #10
                    Ok, So doing an F5 ( NinjaScript Reload ) does not generate the error. It had the same conditions. I checked the Bar Number. I know where my code was because it was placing an Arrow on the screen. Clear picture ? Since All the text objects stopped on the screen when this occurred and since the only one in play on this bar was the ( Arrow ) I am assuming it had to be that one. And In my view there is nothing wrong with the code.

                    tag="arw"+Math.Pow(7,j+2).ToString()+"-"+priceList[m].Bar.ToString();
                    Draw.ArrowUp(this,tag,IsAutoScale, 0, Low[0]-TickSize, dtUp);

                    What exactly are you suggesting? Because I am convinced this is just another Rabbit Hole.
                    and the problem lies elsewhere.

                    Jerry

                    Comment


                      #11
                      Can you clarify what is meant by rabbit hole? The message you sent lets us know for a fact that a runtime variable was uninitialized. This was further isolated by Ninja to userspace, since Ninja stopped execution of your strategy and reported memory associated with your strategy was uninitialized. Debugging userspace code is the only possible means known to me to determine which userspace variable was uninitialized.

                      What I am suggesting is a technique you may use to generate complete code coverage, so that you can "cast a net" to capture what is occurring. The following publicly available link goes into more detail.



                      We are happy to answer any questions we may about NinjaTrader that come up.
                      Jessica P.NinjaTrader Customer Service

                      Comment


                        #12
                        Yes, you chase the rabbit down the hole thinking your going to find him and You Can't because he isn't there. Yesterday with another routine i was getting an error that made no sense.This one was even repeatable. Luckily it was a small piece of code. I took the code appart line by line commenting it out until it had no code it was empty. And guess what it still generated an error. I deleted the indicator from the chart. Deleted, the indicator name and rebuilt it. I still got the error with the code. So I used the Wizard to generate everything except the basic six lines. It still gave me an error. At this point I deleted the chart created a new chart and loaded the indicator. It ran fine. So some how the chart got corrupted. It took me all day yesterday. It's been running all day today with no problems. This is why, what I believe is happening here another corruption for lack of a better word. With little indications of issues with Comma's where they should not be and double Trade markers where they should not be. XML errors when I go to save presets. As I said before I fallback on the fact that There is nothing uninitialized about that Arrow draw object that was executed at the time. And if it was why didn't it error out on Reload. the conditions were the same the code path exactly the same. The same arrow put on the screen. So back to your conclusion about the userspace code being the only way to debug it, That didn't work yesterday with simple code and I cast that net around the whole indicator. I am getting the same kind of inconsistent behavior again. If I monkey around saving presets or doing anything like that I am sure I could generate another error even though it has operated for hours now generating my arrows with no errors.But that doesn't give me any useful information. I am at an absolute loss with this. Explain to me what wrote the comma in my upper left hand corner or how a double execution marker was placed on my screen. My code doesn't do this. Where is it coming from ? I have been distracted all day from trading because of all these issues.

                        Jerry

                        Comment


                          #13
                          Do you have a copy of the six line indicator we may use for testing on our end?
                          Jessica P.NinjaTrader Customer Service

                          Comment


                            #14
                            Jessica,
                            I sent it to Eric under another thread. If its quicker for me to send you a copy I can send it.

                            Comment


                              #15
                              So I answered one of my questions about dual execution markers.
                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by StrongLikeBull, Yesterday, 04:05 PM
                              1 response
                              12 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by Mestor, 03-10-2023, 01:50 AM
                              14 responses
                              375 views
                              0 likes
                              Last Post z.franck  
                              Started by molecool, 10-09-2017, 10:48 AM
                              5 responses
                              1,621 views
                              0 likes
                              Last Post trader-ap  
                              Started by The_Sec, Yesterday, 03:53 PM
                              1 response
                              12 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by mmenigma, Yesterday, 03:25 PM
                              1 response
                              11 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Working...
                              X