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

Hung NT when debugging with VS

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

    Hung NT when debugging with VS

    NT support,

    In the interest of getting NT 7 RC1 to a stable state I thought it best to let you know I just had NT7 RC1 when debugging with Visual Studio 2008.


    I was running a backtest in Strategy Analyzer and debugging in VS; I then had no response from NT7. I had to close it and restart.


    Is there anything you would like me to do?

    Thanks and regards,

    drolles

    #2
    drolles, thanks for reporting this in - if you could contact us via Help > Mail to Support with your trace / logs so we could look into that would be great.

    Thanks,
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Bertrand,


      I've now done that. However, got some sort of error about the email not gonig. Can you please confirm you have it?



      Further to this issue. I’ve been working today on this. I’ve had further hangs with working with VS. When working within some order functions, trying to debug some scripts. I’m no getting NT7 hanging with VS a number of times. I hung once, then came back to me. However, when I was trying to evaluate some variables (i.e. an IOrder object) within VS I got the following information when inspecting the variable:

      From VS 2008
      short_order = {NinjaTrader.Strategy.OrderProxy}
      AvgFillPrice = Function evaluation disabled because a previous function evaluation timed out. You must continue execution to re-enable function evaluation.

      I have never seen these before. Something about function evaluation disable?

      Could you please help here? This has now moved beyond an annoyance to holding strategy development.

      I have attached screenshots of the three screens when I was working.

      Thanks and regards,

      drolles
      Attached Files

      Comment


        #4
        Hi drolles, unfortunately no files sent in have come to my attention here - if you could drop me a note directly to support at ninjatrader dot com and attach your most recent log / trace files (available in the MyDocuments > NinjaTrader 7 / log and trace folders) that would be great.

        Have you tried debugging for example a simpler strategy like our SampleMACrossOver?

        The error message you get can come up when running into issues in multithreaded architectures, are you handling the release of custom resources properly in OnTermination() for your strategy?
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Bertrand,

          Thank you for your continued help.

          I’ve just been reading the documentation with regards to OnTermination(). Thanks for the pointer to that, I will review the documentation to determine if I should be using this method. I can’t think of when I should be using it at the moment. The strategy I’m implementing is not particularly complex. I am, to my knowledge, not kicking off additional threads. I am using the standard NT7 event framework.

          It should be noted that VS / NT7 are not showing this behaviour often. The crashes are happening only occasionally.

          I will try to send the support email again.

          Kind regards,

          drolles

          Comment


            #6
            Bertrand,

            I’ve now managed to narrow down and reproduce this issue – of a form.

            It appears to be within a Position Sizer function I’ve written, and occurs under some very particular conditions. VS appears to continue running, while Strategy Analyser stalls. The other windows within NT stay stable. I’m able to recreate the issue running it against AUDJPY 4 hourly data for this year.

            I’ve included the code of the Position Sizer here. As you can see there isn’t any additional threads kicked off and it does not particularly implement any complex functionality.

            Obviously, I’m unable to narrow down what the issue is with the code as the Strategy Analyser stalls when I’m trying to debug it.

            Any suggestions would be greatly appreciated.

            Kind regards,

            drolles


            Code:
                    public int PositionSize_Hist(double stopsize, int rpercentage) {
                    
                        double CAccountSize = AccountSize + Performance.AllTrades.TradesPerformance.Currency.CumProfit;
                        
                        Print("Current Account Size = "+CAccountSize);
                        
                        if (TickSize.ToString().Length == 6 && stopsize < 1) {
                        
                            stopsize = stopsize * 10000;
                            
                        } else if (TickSize.ToString().Length == 4 && stopsize < 1) {
                        
                            stopsize = stopsize * 100;
                            
                        } else if (TickSize.ToString().Length == 4 && stopsize > 1) {
                        
                            stopsize = stopsize * 100;
                            
                        } else if (TickSize.ToString().Length == 6 && stopsize > 1) {
                        
                            stopsize = stopsize * 10000;
                            
                        }
                        
                        double cap_percentage = (double)rpercentage / 100;
                        
                        int PSize = (int)Math.Round((CAccountSize * cap_percentage) / stopsize);
                        
                        // Can't trade less than a single lot
                        if (PSize < 1)
                            PSize = 1;
                        
                        if (Historical) {
                            
                            if (Instrument.MasterInstrument.InstrumentType == InstrumentType.Currency) { // trade lots
                            
                                return (PSize * 10000);
                                
                            } else if (Instrument.MasterInstrument.InstrumentType == InstrumentType.Stock) {
                                
                                return (PSize);
                                
                            } else {
                            
                                return (PSize);
                                
                                Print("Error - unknown instrument type - 70 @ Risk Manager");
                                
                            }

            Comment


              #7
              Hi drolles, unfortunately I would not see any strikingly offending logic there either, if you comment out parts of the logic can you circle in an area that would lead to the hangs in your testing?
              BertrandNinjaTrader Customer Service

              Comment


                #8
                As this was not covered, what version of VS are you using?
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Josh,

                  Thanks for the reponse.

                  The VS version is 2008.

                  Thanks and regards,

                  drolles

                  Comment


                    #10
                    Thanks drolles, is this the VS standard or express version you're running?
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Bertrand,

                      It is standard.

                      Thanks and regards,

                      drolles

                      Comment


                        #12
                        Thanks drolles, what I would then need from you is the exact testing scenario (your settings, breakpoints, instrument to backtest on, sessions, data provider) you use to reproduce the issue and your strategy code including the PositionSize part that you previously narrowed it down to being likely the 'culprit. You can contact me directly at support at ninjatrader dot com with this info.

                        Thanks in advance,
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          Bertrand,

                          Just for completeness I thought I best circle around on this.

                          I’ve been focused elsewhere recently so I haven’t been working with this functionality for a while. But over the last couple of days I’ve become focused on it. I’ve narrowed to the problem to top portion of the code checking for stop size and ticksize.


                          Code:
                          if (TickSize.ToString().Length == 6 && stopsize < 1) {
                                      
                                          stopsize = stopsize * 10000;
                                          
                                      } else if (TickSize.ToString().Length == 4 && stopsize < 1) {
                                      
                                          stopsize = stopsize * 100;
                                          
                                      } else if (TickSize.ToString().Length == 4 && stopsize > 1) {
                                      
                                          stopsize = stopsize * 100;
                                          
                                      } else if (TickSize.ToString().Length == 6 && stopsize > 1) {
                                      
                                          stopsize = stopsize * 10000;
                                          
                                      }
                          It appeared to be returning very erroneous results for the position size. After I changed the code it appears to be working and NT is not hanging. I don’t know what it was, but something in there really wasn’t working. It was funny as it only appeared to affect a single instrument AUDJPY.

                          Thanks and regards,

                          drolles

                          Comment


                            #14
                            drolles,

                            Not exactly sure how the code you have posted there would impact anything but the stopsize variable. If you want to know what exactly the calculations are doing it would be best to try and trace out each calculation each step of the way so you can see a before/after effect.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Josh,

                              Thanks for the reply.

                              I agree with you. While the code doesn’t make any sense in hindsight (it was a long time ago that I wrote it), it wouldn’t appear to be any problems with it logically.

                              I’m happy to work with you on it if you like. However, as per the previously post I’ve removed the front portion of the code and the error is gone.

                              Would you like me to forward the code to the support address?

                              Kind regards,

                              drolles

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by cshox, Today, 11:11 AM
                              2 responses
                              12 views
                              0 likes
                              Last Post cshox
                              by cshox
                               
                              Started by algospoke, Today, 06:53 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post algospoke  
                              Started by mlprice12, 12-21-2021, 04:55 PM
                              3 responses
                              292 views
                              0 likes
                              Last Post paypachaysa  
                              Started by lorem, 04-25-2024, 09:18 AM
                              20 responses
                              85 views
                              0 likes
                              Last Post lorem
                              by lorem
                               
                              Started by xepher101, 05-10-2024, 12:19 PM
                              4 responses
                              52 views
                              0 likes
                              Last Post xepher101  
                              Working...
                              X