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

NT Crash

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

    NT Crash

    Hello!

    I'v have had several NT crashes since yesterday.
    My Windows log:

    Code:
    Version=1
    EventType=APPCRASH
    EventTime=130491931139162871
    ReportType=2
    Consent=1
    UploadTime=130491931139630872
    Response.BucketId=39162846
    Response.BucketTable=20
    Response.type=4
    Sig[0].Name=Application Name
    Sig[0].Value=NinjaTrader.exe
    Sig[1].Name=Application Version
    Sig[1].Value=7.0.1000.14
    Sig[2].Name=Application Timestamp
    Sig[2].Value=51c1e199
    Sig[3].Name=Fault Module Name
    Sig[3].Value=KERNELBASE.dll
    Sig[4].Name=Fault Module Version
    Sig[4].Value=6.1.7601.18409
    Sig[5].Name=Fault Module Timestamp
    Sig[5].Value=5315a05a
    Sig[6].Name=Exception Code
    Sig[6].Value=[COLOR=Red]e053534f[/COLOR] ("soft stack overflow" raised by the CLR)
    Sig[7].Name=Exception Offset
    Sig[7].Value=000000000000940d
    This crash occurs either when I relaod NinjaScript on a chart after I have modified and compiled a specific indicator or when I start NT and this indicator is attached to a chart in the open workspace. The indicator is huge (25 000 lines), but the development has worked fine for several month until yesterday. The crash occurs regardless if this indicator draws any objects on the chart or not. This problem seems intermittent since NT suddenly stopped crashing yesterday eavening when I was working on this indicator but then started to crash again when I opened NT this morning. What can I do?

    Best Regards
    posedon_sthlm
    Last edited by poseidon_sthlm; 07-07-2014, 04:28 AM.

    #2
    poseidon_sthlm, we would need to isolate and find out from which condition / section exactly the issue arises. So I would ask you to look into what changes you have done recently to the study around the time the issue started to manifest. Also you seem to be using the outdated R14 release on this machine in your testing still? Would upgrading to latest R24 of NT7 have any effect on the outcomes seen?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      You need to debug your indicator. Also have a look at the NinjaTrader log and trace files. If you are lucky you will find an error message somewhere.

      Comment


        #4
        The reason for my NT crashes may be a custom method in another added indicator (indicator on indicator) that is called several times by the main indicator. (The method is also called in a loop from the main indicator). Is it possible that this method hasn't finished the calculations from a prior call when it is called anew, and that this causes a crash when NT is calculating the indicator for the historical bars on the chart? If this is a valid assumption, how can I prevent this situation? How can I prevent that the method is called a second time before it has returned the result for the first call?

        Best Regards,
        poseidon_sthlm

        Comment


          #5
          Hi poseidon_sthlm, unless you have introduced custom threading that should not be a plausible scenario since it could not happen under the default NT7 threading as your NinjaScript would run on one thread. The stacktrace would not be very helpful to pinpoint, we would suggest adding try / catch statements throughout your code isolating the functional groups and then log the exception details to understand better. Another 'last resort' thought would be attaching your study to the VS debugger to see if more granular details could be traced this way when this issue unfolds.
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Is is safe to close NT and then delete the files in the folder: \NinjaTrader 7\cache ?

            /poseidon_sthlm

            Comment


              #7
              Yes, would be rebuilt next time you open your NS editor.
              BertrandNinjaTrader Customer Service

              Comment


                #8
                Is it possible that the condition (CurrentBar == -1) can be true for any situation when NT calculates the historical indicator values for a chart when I reload NinjaScript?

                Comment


                  #9
                  I would not expect that, since CurrentBar would not make any historical vs realtime distinction. 0 would be your leftmost bar and then it would build up until right most bar is reached. Single vs MultiSeries scripts will have a bit different processing as single series would always process to the current visible bar only, while MultiSeries would work through all bars regardless.
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    After many, many hours of trouble shooting I belive that I have found a clue to where to look for the cause of my NT crashes. The crash only occurs in the 64-bit NT version but not in the 32-bit version. I have been using the 64-bit version for a long time and haven't experienced any issues until now.

                    The crash occurs when NT (64-bit) is recalculating historical indicator values for a chart when I do "Reload Ninjascript". My indicator is calculation intensive since I copied all my custom indicators into one indicator file. (For computation efficiency reasons I only want one instance of each referenced indicator created.) I use the c# classes Collections.Generic and Linq and I shuffle a lot of data in several custom structs in several generic List(T) and IEnumerables.

                    I have reviewed my entire code thorough and isolated every part of it. (And I do have eliminted possible unwanted deferred execution issues). The try-catch blocks do not cast any error messages. I mentioned above that the issue seemed intermittent. Once NT succeeds to calculate the historical values the issue disappears . I suppose that this is because the indicator historiy is cahced and reused the next time you do "Reload ". But the strangest thing is that no matter what part of the code I do eliminate (with if (false){} ) , as long as it is large enough, the issue diasppears. So it seems to me as if I hit some CPU threshold. When I filter for NT in the Resource Monitor in Windows it shows that the frequency is 109% before NT crashes.

                    I do want to use the 64-bit NT version for obvious reasons. How can I continue to solve this issue?

                    Best Regards
                    posedon_sthlm

                    Comment


                      #11
                      posedon_sthlm, I have reviewed with development and from the stack trace they feel the issue arises from a too deep recursive call of your custom methods / properties used in the script.

                      Some background would be for example explained here - http://joel.inpointform.net/software...tack-overflow/

                      If you're having access to a debugger or profiler that would likely be helpful to see exactly where most of your time / memory is spend while the code executes.
                      BertrandNinjaTrader Customer Service

                      Comment


                        #12
                        Another thought would be looking into converting code to use methods that would use the heap instead of the stack (value types vs reference types).
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          Can you recommend a debugging software that is affordable and doesn't have a steep learning curve? I'm not a programmer, just a NT amateur developer (as you may already have guessed).

                          I want to clarify that the structs that I use in my indicators are just simple instance constructors that I use to model TA patterns. I have declared all my structs in the 'myCutomIndicatorMethods' file. Some of these structs implement the interfaces IComparer<T> and IEquatable<T>. I have not created any other advanced custom methods related to these structs. (But I do use the maxBy()/minBy() Linq extension methods in the MoreLinq namespace created by Jon Skeet.) Do you think that the use of classes instead of structs for the instance contstuctors in my case would substantially lower the use of the stack? (Code example below)

                          I still find it strange that my indicator runs flawless in the 32-bit NT version but crashes in the 64 bit version. How can this be?


                          Should I replace this in the 'MyCustomIndicatorMetods' file:
                          Code:
                          #region DataPoint : IEquatable<DataPoint>
                                          
                                          public [COLOR=Red][B]struct[/B][/COLOR] DataPoint : IEquatable<DataPoint>
                                          {
                                              public int barNo;
                                              public double value;
                                                          
                                              public DataPoint(int dpBNo, double dpV)
                                              {
                                                  this.barNo = dpBNo;
                                                  this.value = dpV;
                                              }
                                              
                                              
                                              #region Equals()
                                              
                                              public bool Equals(DataPoint other) 
                                              {
                                                  if (this.barNo.Equals(other.barNo)
                                                      && this.value.Equals(other.value) )
                                                  {
                                                      return true;
                                                  }
                                                  else 
                                                  {
                                                      return false;
                                                  }
                                              }
                          
                                              // Override Object.Equals(object)
                                              public override bool Equals(object obj)
                                              {
                                                  if ( obj is DataPoint)
                                                  {
                                                      return this.Equals((DataPoint)obj);
                                                  }
                                                  else 
                                                  {
                                                      return false;
                                                  }
                                              }  
                                              
                                              
                                              public override int GetHashCode()
                                              {
                                                  int hashValue     = this.value.GetHashCode();
                                                  int hCode         = this.barNo ^ hashValue;
                                                  return hCode.GetHashCode();
                                              }
                                              
                                              
                                              public static bool operator == (DataPoint d1, DataPoint d2)
                                              {
                                                  return d1.Equals(d2);
                                              }
                          
                                              
                                              public static bool operator != (DataPoint d1, DataPoint d2)
                                              {
                                                  return ! (d1.Equals(d2));
                                              }
                                              
                                              #endregion
                                          
                                          }
                                          
                                          #endregion
                          ... with this?

                          Code:
                          #region DataPoint : IEquatable<DataPoint>
                                      
                                      public [B][COLOR=Red]class[/COLOR][/B] DataPoint : IEquatable<DataPoint>
                                      {
                                          public int barNo;
                                          public double value;
                                          
                                          // Default Constructor
                                          public DataPoint()
                                          {
                                              barNo = -1;
                                              value = -1.0;
                                          }
                                          
                                          public DataPoint(int dpBNo, double dpV)
                                          {
                                              this.barNo = dpBNo;
                                              this.value = dpV;
                                          }
                                          
                                          
                                          #region Equals()
                                          
                                          public bool Equals(DataPoint other) 
                                          {
                                              if (other == null)
                                              {
                                                   return false;
                                              }
                                                  
                                              if (this.barNo.Equals(other.barNo)
                                                  && this.value.Equals(other.value) )
                                              {
                                                  return true;
                                              }
                                              else 
                                              {
                                                  return false;
                                              }
                                          }
                          
                                          // Override Object.Equals(object)
                                          public override bool Equals(object obj)
                                          {
                                               if (obj == null)
                                              {
                                                   return false;
                                              }
                                              
                                               // If parameter cannot be cast to DataPoint return false.
                                              DataPoint dataPointObj = obj as DataPoint;
                                              
                                              if ( dataPointObj == null )
                                              {
                                                  return false;
                                              }
                                              else 
                                              {
                                                  return Equals((DataPoint)obj);
                                              }
                          
                                          }  
                                          
                                          
                                          public override int GetHashCode()
                                          {
                                              int hashValue     = this.value.GetHashCode();
                                              int hCode         = this.barNo ^ hashValue;
                                              return hCode.GetHashCode();
                                          }
                                          
                                          
                                          public static bool operator == (DataPoint d1, DataPoint d2)
                                          {
                                              if ((object)d1 == null || ((object)d2) == null)
                                              {
                                                   return Object.Equals(d1, d2);
                                              }
                                              
                                              
                                              return d1.Equals(d2);
                                          }
                          
                                          
                                          public static bool operator != (DataPoint d1, DataPoint d2)
                                          {
                                              if (d1 == null || d2 == null)
                                                  return ! Object.Equals(d1, d2);
                          
                                              return ! (d1.Equals(d2));
                                          }
                          
                                          #endregion
                                      
                                      }
                                      
                                      #endregion
                          Best Regards,
                          poseidon_sthlm
                          Last edited by poseidon_sthlm; 07-12-2014, 01:34 PM.

                          Comment


                            #14
                            poseidon_sthlm, 32 vs 64 bit would definitely have internally differences in memory management so I would not be surprised seeing those manifest in your scenario. First thing you could look into is attaching to the Visual Studio Express debugger (newer version have an attach to option now) - https://www.ninjatrader.com/support/..._debugging.htm. Moving from the struct to the class (reference type) should free up the heap, yes.
                            BertrandNinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by GussJ, 03-04-2020, 03:11 PM
                            16 responses
                            3,276 views
                            0 likes
                            Last Post Leafcutter  
                            Started by WHICKED, Today, 12:45 PM
                            2 responses
                            19 views
                            0 likes
                            Last Post WHICKED
                            by WHICKED
                             
                            Started by Tim-c, Today, 02:10 PM
                            1 response
                            8 views
                            0 likes
                            Last Post NinjaTrader_ChelseaB  
                            Started by Taddypole, Today, 02:47 PM
                            0 responses
                            5 views
                            0 likes
                            Last Post Taddypole  
                            Started by chbruno, 04-24-2024, 04:10 PM
                            4 responses
                            51 views
                            0 likes
                            Last Post chbruno
                            by chbruno
                             
                            Working...
                            X