Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT8 B11: Platform crashes with the same error

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

    NT8 B11: Platform crashes with the same error

    We have developed our indicators in the new NT8 version 11. We were able to make a stable release since about version 9 and have recently been catching up with the changes. We run our indicators for a few minutes then the platform crashes without any errors in the logs or output window. But in the trace files these are the lines that appear before the crash happens:

    2016-06-03 22:22:54:687 Gui.Chart.ChartPanel.OnRender: System.IndexOutOfRangeException: Index was outside the bounds of the array.
    at NinjaTrader.NinjaScript.NinjaScriptBase.get_Bars()
    at NinjaTrader.Gui.NinjaScript.IndicatorRenderBase.Ca lculateMinMax()
    at NinjaTrader.Gui.Chart.ChartScale.CalculateMinMax()
    at NinjaTrader.Gui.Chart.ChartPanel.CalculateMinMax()
    at NinjaTrader.Gui.Chart.Direct2DForm.RenderInit()

    I'm attaching a few trace files here as well as these are the only places that I find a clue of the error. Please notice the last lines. I hope you can help as we are constantly keeping up with the changes every time a new beta version is released. Thanks in advance!
    Attached Files

    #2
    Hi karlomacariola,

    I am seeing that the error is likely coming from OnRender and the error is an index error.

    Are you calling bar information without using <series>.GetClose() or <customseries>.GetValueAt(), or instead using TriggerCustomEvent() to sync the bar series before calling a particular bar?

    For example, calling Close[0] in OnRender without calling this in TriggerCustomEvent might cause that error.

    GetClose - http://ninjatrader.com/support/helpG...s/getclose.htm
    GetValueAt - http://ninjatrader.com/support/helpG...getvalueat.htm
    TriggerCustomEvent - http://ninjatrader.com/support/helpG...ustomevent.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea. Thank you for the prompt reply! I never realized that using GetClose(i) and Close[i] makes a huge difference. I am going to follow your advise and review my code. I'll let you know how I get on.

      Comment


        #4
        Hi karlomacariola,

        With any method that is not a data driven method (such as OnBarUpdate, OnMarketData, OnMarketDepth) then the data series will not be synchronized.

        When in a non-data-driven method, calling TriggerCustomEvent() will synchronize the data series so that the indexes will be correct.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Chelsea. Many thanks again for your advice and for introducing me to TriggerCustomEvent. The only non-data driven method that I have is a Timer event (no OnRender) which does not call any DataSeries and yet I still get this error. The only thing my Timer event does is that it flips a boolean variable for each tick. I'm thinking about changing all my Close[], Open[], High[] etc to GetClose(), GetOpen() and GetHigh() but I wonder if this will help at all.

          Another thing worth mentioning is that I get the error after a while. I can't predict when it will happen.
          Last edited by karlomacariola; 06-06-2016, 07:59 AM.

          Comment


            #6
            Hi karlomacariola,

            A custom timer would be a non-data-driven event that would need to use TriggerCustomEvent or .GetClose / .GetValueAt.

            Are you receiving this error when using TriggerCustomEvent in the timer?
            Do you have an example of this I may test?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi Chelsea. It is difficult to isolate what triggers the error as I cannot predict when it happens so I cannot send you code that will surely replicate it. What I can assure you is that our indicators do not have custom code in OnRender. Some of our indicators use a Timer event but none of these events ever call Close[], Open[], or other DataSeries. They are all in OnBarUpdate. I'm testing further our indicators in attempt to find the cause. The platform always crashes after I leave it running with several charts open (with our indicators) and the same error appears in the trace files. I will also try running the native indicators with the same number of charts open and see if the platform will still crash.

              2016-06-07 22:26:00:783 Gui.Chart.ChartPanel.OnRender: System.IndexOutOfRangeException: Index was outside the bounds of the array.
              at NinjaTrader.NinjaScript.NinjaScriptBase.get_Bars()
              at NinjaTrader.Gui.NinjaScript.IndicatorRenderBase.Ca lculateMinMax()
              at NinjaTrader.Gui.Chart.ChartScale.CalculateMinMax()
              at NinjaTrader.Gui.Chart.ChartPanel.CalculateMinMax()
              at NinjaTrader.Gui.Chart.Direct2DForm.RenderInit()

              It's worth mentioning that not all of our indicators use a Timer. I recently tested those and I still got the error above in the trace files. I had about 4 currency charts open with some of them have multiple tabs running. The charts were running our most basic indicators - no Timers or other fancy events. Just the standard OnBarUpdate and OnStateChange initializations.
              Last edited by karlomacariola; 06-07-2016, 09:31 AM.

              Comment


                #8
                We have also tried it in different locations (East Asia and UK) but we get the same error message in the trace file when the platform crashes. As soon as I find the right conditions to trigger this particular outcome I will send the source code to you.
                Last edited by karlomacariola; 06-07-2016, 09:30 AM.

                Comment


                  #9
                  Hello karlomacariola,

                  If you are not using the OnRender method in the script then likely its not coming from this.

                  It may be coming from a custom timer.

                  Have you added prints to your script every few lines to track down which line is causing the error?

                  Are you doing a checks for all collections and arrays that the index being called is a valid index?

                  if (myArray.Count > 2)
                  Print(myArray[2]);

                  if (Close.IsValidDataPoint(2))
                  Print(Close[2]);

                  Can you make a test script that just includes the small code that is causing the error and post this with your next post?

                  To export a NinjaTrader 8 NinjaScript do the following:
                  1. Click Tools -> Export -> NinjaScript...
                  2. Click the 'add' link -> check the box(es) for the script(s) you want to include
                  3. Click the 'Export' button
                  4. Enter a unique name for the file in the value for 'File name:'
                  5. Choose a save location -> click Save
                  6. Click OK to clear the export location message

                  By default your exported file will be in the following location:
                  • (My) Documents/NinjaTrader 8/bin/Custom/ExportNinjaScript/<export_file_name.zip>


                  Below is a link to the help guide on Exporting NinjaScripts.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Hi Chelsea. Many thanks again for your prompt reply. I will try to add additional checks to my collections like you suggested. I'll send you a sample code if I still encounter this error even after all the validations. Thanks again and I'll get back to you soon.

                    Comment


                      #11
                      Error still occurring in NT8 B12

                      Hi Chelsea,

                      Sorry for the very late response to this thread. Just to let you know I have upgraded to NT8 version 12 as soon as I heard it came out and I've been back at working on our indicators on this platform. I followed your instruction which is to make sure that all arrays were validated before being referenced. In fact I followed this religiously that most validations have become redundant. I also used the IsValidDataPoint() method in each of my DataSeries calls. Despite these I still get the same, exact error I mentioned at the beginning of this thread. Just to refresh you I get the following error in the trace files before the platform crashes:

                      2016-07-27 15:20:36:473 Gui.Chart.ChartPanel.OnRender: System.IndexOutOfRangeException: Index was outside the bounds of the array.
                      at NinjaTrader.NinjaScript.NinjaScriptBase.get_Bars()
                      at NinjaTrader.Gui.NinjaScript.IndicatorRenderBase.Ca lculateMinMax()
                      at NinjaTrader.Gui.Chart.ChartScale.CalculateMinMax()
                      at NinjaTrader.Gui.Chart.ChartPanel.CalculateMinMax()
                      at NinjaTrader.Gui.Chart.Direct2DForm.RenderInit()

                      Please note that I don't override OnRender. I cannot tell when this would occur but it is usually how the session ends - with the platform crashing and these lines at the end of the trace file. I am attaching here a very stripped down code of one of our indicators which uses a few of the most basic NinjaScript methods. It's also worth mentioning that it is calling multiple currency pairs or data series. You will need to wait for an hour, a few, or even several hours for the error to happen but I assure you that it does happen eventually. I tested this with only one chart open with this indicator attached.

                      I saw a new post today from user Lord Devil which I think is closely related to this issue. His post is found here: http://ninjatrader.com/support/forum...ad.php?t=87813

                      I look forward to your reply and I hope you can resolve this soon. Many thanks once again for your assistance.

                      Karlo
                      Attached Files

                      Comment


                        #12
                        Hello karlomacariola,

                        Thank you for including the script.

                        I am seeing there could be an order of operations error.

                        On every bars in progress these plots are set. This means, it will set all 7 plots, 8 times on every bar. So on every bar, there are 56 set events. On the first update, there might not be bar information for the other bars in Progress and hits an index error.

                        You could set each plot when the input source for that RSI call has OnBarUpdate trigger with that BarsInProgress.
                        Code:
                        if (BarsInProgress == 1)
                        Plot1[0] = RSI(Opens[1], 14, 1)[0];
                        
                        if (BarsInProgress == 2)
                        Plot2[0] = RSI(Closes[2], 14, 1)[0];
                        etc..
                        Then the plots would only be set when that BarsInProgress updates for the Opens, Closes etc.

                        Or you could but a check in to make sure each plot has at least one bar
                        Code:
                        for (int i = 0; i < 8; i++)
                        {
                        	if (CurrentBars[i] < 1)
                        		return;
                        }
                        As a heads up, I tested this script on my end and I did not get any errors. You may want to double check that this is the script causing the error.
                        Attached Files
                        Last edited by NinjaTrader_ChelseaB; 07-29-2016, 11:02 AM.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Error in the test code with screenshot and trace file

                          Hi Chelsea,

                          Thanks for responding. I went back to testing as soon as the markets opened again. I followed your advice and have revised the code to the following:

                          Code:
                          protected override void OnBarUpdate()
                          		{
                          			//Add your custom indicator logic here.	
                          			
                          			for (int i = 0; i < 8; i++)
                          			{
                          				if (CurrentBars[i] < 1)
                          					return;
                          			}
                          			
                          			if(BarsInProgress == 1) {
                          				if(Opens[1].IsValidDataPoint(0))
                          					Plot1[0] = RSI(Opens[1], 14, 1)[0];
                          			}
                          			if(BarsInProgress == 2) {
                          				if(Closes[2].IsValidDataPoint(0))
                          					Plot2[0] = RSI(Closes[2], 14, 1)[0];
                          			}
                          			if(BarsInProgress == 3) {
                          				if(Highs[3].IsValidDataPoint(0))
                          					Plot3[0] = RSI(Highs[3], 14, 1)[0];
                          			}
                          			if(BarsInProgress == 4) {
                          				if(Lows[4].IsValidDataPoint(0))
                          					Plot4[0] = RSI(Lows[4], 14, 1)[0];
                          			}
                          			if(BarsInProgress == 5) {
                          				if(Opens[5].IsValidDataPoint(0))
                          					Plot5[0] = RSI(Opens[5], 14, 1)[0];
                          			}
                          			if(BarsInProgress == 6) {
                          				if(Closes[6].IsValidDataPoint(0))
                          					Plot6[0] = RSI(Closes[6], 14, 1)[0];
                          			}
                          			if(BarsInProgress == 7) {
                          				if(Highs[7].IsValidDataPoint(0))
                          					Plot7[0] = RSI(Highs[7], 14, 1)[0];
                          			}
                          		}
                          I saved, compiled it, then ran it in an EURUSD chart. It is the only chart in the workspace. About 30 minutes in and I got this error:



                          As a heads up, I tested this script on my end and I did not get any errors. You may want to double check that this is the script causing the error.
                          This is the only indicator/script open in the workspace which only has a single chart. I'm pretty sure it's the one causing the error unless it is possible for unopened custom indicators to cause this sort of behaviour?
                          Attached Files

                          Comment


                            #14
                            Several things to try here. (Dpes look like there is an issue in OnRender, wouldn't be the first time).

                            Put a Print statement to see the value before NT blows up.

                            That might shed some light on the issue.

                            Code:
                            			if(BarsInProgress == 1) {
                            				if(Opens[1].IsValidDataPoint(0))
                                                             {
                                                                 Print ( "RSI(Opens[1],14,1)[0]=" + RSI(Opens[1],14,1)[0] )
                            
                            					Plot1[0] = RSI(Opens[1], 14, 1)[0];
                            			}
                            }

                            Next I would try:

                            Code:
                            			if(BarsInProgress == 1) {
                            				if(Opens[1][B][0][/B].IsValidDataPoint(0))
                                                             {
                                                                 Print ( "RSI(Opens[1][B][0][/B],14,1)[0]=" + RSI(Opens[1][B][0][/B],14,1)[0] )
                            
                            					Plot1[0] = RSI(Opens[1][B][0][/B], 14, 1)[0];
                            			}
                            }

                            Comment


                              #15
                              Thanks sledge. I'll try this and I'll post what I find. BTW I don't override OnRender.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by maybeimnotrader, Yesterday, 05:46 PM
                              2 responses
                              21 views
                              0 likes
                              Last Post maybeimnotrader  
                              Started by adeelshahzad, Today, 03:54 AM
                              5 responses
                              32 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by stafe, 04-15-2024, 08:34 PM
                              7 responses
                              32 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by merzo, 06-25-2023, 02:19 AM
                              10 responses
                              823 views
                              1 like
                              Last Post NinjaTrader_ChristopherJ  
                              Started by frankthearm, Today, 09:08 AM
                              5 responses
                              22 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Working...
                              X