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

Chart Error

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

    Chart Error

    Hi,

    I have a strage problem.

    If I load my indicator on chart when Market Replay is playing, my 8 Range Chart is gone and the indicator deactivated.

    Here are some attachments (and the indicator):

    Click image for larger version

Name:	CL 05-11 (8 Range)  3_23_2011.jpg
Views:	1
Size:	110.5 KB
ID:	897059

    Click image for larger version

Name:	CL 05-11 (8 Range)  3_23_2011_after.jpg
Views:	1
Size:	112.4 KB
ID:	897061

    aTrend2.zip

    Is this a NT bug?

    Can you help me with this problem?

    Thank you.

    #2
    Please check your Log tab for runtime errors. This looks to be a case of erroneous indicator coding which ran into an issue and could not continue running.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      This is the error:

      Error on calling 'OnBarUpdate' method for indicator 'aTrendEnter' on bar 56: Object reference not set to an instance of an object.
      I have another indicators with the same code (and no errors), but this one has the following condition:

      if (Close[i] > Open[i-2] && High[i-2] < Close[i-8])
      If this condition is part of any indicators I have, I get the same error.

      What is wrong with this condition?

      Comment


        #4
        It is not necessarily the condition at fault, but somewhere else in your code. Please use try-catch blocks throughout your code to isolate out where exactly in your code it is running into the issues on bar 56.

        For more information on try-catch blocks please see here: http://www.ninjatrader.com/support/f...ead.php?t=9825
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          The same problem

          Here is what I have in output window after try-catch:

          3/23/2011 8:36:54 AM System.NullReferenceException: Object reference not set to an instance of an object.
          at NinjaTrader.Data.MemBars.GetOpen(Int32 index)
          at NinjaTrader.Data.Bars.GetOpen(Int32 index)
          at NinjaTrader.Indicator.DataSeriesHelper.get_Item(In t32 barsAgo)
          at NinjaTrader.Indicator.aTrend2.OnBarUpdate()
          This is my try-catch code:

          Code:
          for (int i = 0, a = 1, b = 1, c = 2, d = 3; i < Period; i++, a++, b++, c++, d++)
          				
          				
          				
                  	{
          				try {
          					if (Close[i] > Open[i-2] && High[i-2] < Close[i-8])
          						var2 = var2 + 1;
          				}
          				
          				catch (Exception e)
          						
          			
          			{
          				/* With our caught exception we are able to generate log entries that go to the Control Center logs and also print more detailed information
          				about the error to the Output Window. */
          				
          				// Submits an entry into the Control Center logs to inform the user of an error
          				Log("SampleTryCatch Error: Please check your indicator for errors.", LogLevel.Error);
          				
          				// Prints the caught exception in the Output Window
          				Print(Time[0] + " " + e.ToString());
          			}
          					
          			
          			}
          			
          			Short.Set(var2);
          Is there something wrong with the code I wrote?
          Last edited by SymeBB; 06-28-2011, 12:11 AM.

          Comment


            #6
            Debbuging in Visual Studio shows no error.

            Comment


              #7
              SymeBB,

              Please try-catch the whole code everywhere. Leave nothing in OnBarUpdate() outside of a try-catch block. Using different print statements from the try-catch block will allow you to identify which one exactly is printing.

              But actually if the output you are saying is coming from the try-catch block you have already then that is fine. What you would need to do next is to isolate the individual component from within that block that is causing the issue with additional try-catchs.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                But how can I go deeper in that code?

                I have isolated this condition:

                if (Close[i] > Open[i-2] && High[i-2] < Close[i-8])
                Is there some way I can go deeper in?

                Comment


                  #9
                  Break your if-statement into multiple parts and try-catch each section. Then debug it with Print() statements.

                  By looking at your code it is highly possible that you are just passing in invalid [] index values.

                  i=0 means you are trying to do Open[-2]. You cannot have negative index values.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    That [i-2] is resolved as follows:

                    if(CurrentBar < Period + 9)
                    return;
                    It is not the case to have invalid index values.

                    Comment


                      #11
                      SymeBB,

                      Then all I can advise is to continue debugging and break down the bricks even further.
                      Josh P.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by usazencort, Today, 01:16 AM
                      0 responses
                      1 view
                      0 likes
                      Last Post usazencort  
                      Started by kaywai, 09-01-2023, 08:44 PM
                      5 responses
                      603 views
                      0 likes
                      Last Post NinjaTrader_Jason  
                      Started by xiinteractive, 04-09-2024, 08:08 AM
                      6 responses
                      22 views
                      0 likes
                      Last Post xiinteractive  
                      Started by Pattontje, Yesterday, 02:10 PM
                      2 responses
                      21 views
                      0 likes
                      Last Post Pattontje  
                      Started by flybuzz, 04-21-2024, 04:07 PM
                      17 responses
                      230 views
                      0 likes
                      Last Post TradingLoss  
                      Working...
                      X