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

Catching NinjaTrader internal exception

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

    Catching NinjaTrader internal exception

    Hi NinjaTrader,

    I would like to catch this exception within my own indicator code vs allowing it to trace thru back to the NinjaTrader application. It is occurring from IndicatorBase which is in the "do not touch" portion of the indicator created code. Would it be OK for me to catch this in Indicator: IndicatorBase (a do not disturbe NinjaScript generated code) vs allowing it to go unhandled?

    2014-10-06 06:30:02:044 in OnUnhandledThreadException
    2014-10-06 06:30:02:185 *************** unhandled exception trapped ***************
    2014-10-06 06:30:02:185 Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
    2014-10-06 06:30:02:185 at System.Collections.ArrayList.get_Item(Int32 index)
    at NinjaTrader.Data.MemBars.GetClose(Int32 index)
    at NinjaTrader.Data.Bars.GetClose(Int32 index)
    at NinjaTrader.Indicator.DataSeriesHelper.get_Item(In t32 barsAgo)
    at NinjaTrader.Indicator.IndicatorBase.Process(Object sender, BarUpdateEventArgs e)
    at NinjaTrader.Data.MarketDataEventArgs.Process()
    at NinjaTrader.Cbi.Connection.OnRealtimeDataTimerTick (Object sender, EventArgs e)
    at System.Windows.Forms.Timer.OnTick(EventArgs e)
    at System.Windows.Forms.Timer.TimerNativeWindow.WndPr oc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    #2
    Hi number1,

    Thank you for your post.

    Are there any bars on the chart this indicator was added to?

    If you add this indicator to a chart with data does this error still occur?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Chelsea,

      Thank you for getting back so quickly. No this exception only occurs before a bar has been created occurring a "moment" after the session starts.

      Number1

      Comment


        #4
        Hi number1,

        Does adding a check for the CurrentBar being greater than one for any processing to happen correct the script?

        For example:

        if (CurrentBar < 1)
        return;


        The error is saying there is no data on the chart which causes an error with indexes.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Chelsea,

          Thank you. Let me add that and test on tomorrows open.

          Regards,

          Number1

          Comment


            #6
            Chelsea,

            I tested and the exception is still occurring. I already place a Try/Catch in the OnBarUpdate catching the entire routine.

            Question: Shouldn't that Try/Catch inside and enclosing OnBarUpdate catch the exception without flowing back to NinjaTrader?


            The exception is occurring with a multi security Bar indicator using tick data.

            Thanks for researching.

            Number1

            Comment


              #7
              Hi number1,

              The try and catch would need to be within the OnBarUpdate method, not containing it.

              May I test your script on my end?

              To export your script do the following:
              1. Click File -> Utilities -> Export NinjaScript
              2. Enter a unique name for the file in the value for 'File name:'
              3. Select the strategy from the objects list on the left -> click the right facing arrow ">" to add the strategy to the export
              4. Click the 'Export' button -> click 'yes' to add any referenced indicators to the export -> click OK to clear the export location message


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


              Below is a link to the help guide on Exporting NinjaScripts.
              http://www.ninjatrader.com/support/h...nt7/export.htm

              If you would like to keep the script private, please let me know and I will have you email this in to support.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Chelsea,

                Obviously the try/catch is inside the OnBarUpdate.... "inside and enclosing OnBarUpdate". I know you deal with inexperienced programmers... but please that's kind of an insult...


                I will email from outside. Thanks.

                Comment


                  #9
                  Hello number1,

                  I was not trying to insult you.

                  I was responding to this specific text
                  Shouldn't that Try/Catch inside and enclosing OnBarUpdate catch the exception without flowing back to NinjaTrader?
                  The enclosing here is what I am focusing on and just wanting to ensure that this is done correctly.

                  Please send your script to platformsupport [at] ninjatrader [dot] com. In the email please include a link to this forum thread.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    I understand. Sorry I specifically phrased it as "inside and enclosing" so that it would be perfectly clear and that I wasn't clueless with where to put try/catch statements.. Regardless, I am experienced with try/catch and exception handling so we can move on with that assumption.

                    I will forward the indicator. Please confirm that you have real-time feed access to both CME GLOBEX and Kinetick exchanges, otherwise this is wasting both our time.

                    Comment


                      #11
                      Chelsea,

                      I will need some time to remove local objects and references that will cause the script to fail on your side. Please give me a few days! Thanks.


                      Number1

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Jon17, Today, 04:33 PM
                      0 responses
                      1 view
                      0 likes
                      Last Post Jon17
                      by Jon17
                       
                      Started by Javierw.ok, Today, 04:12 PM
                      0 responses
                      4 views
                      0 likes
                      Last Post Javierw.ok  
                      Started by timmbbo, Today, 08:59 AM
                      2 responses
                      10 views
                      0 likes
                      Last Post bltdavid  
                      Started by alifarahani, Today, 09:40 AM
                      6 responses
                      40 views
                      0 likes
                      Last Post alifarahani  
                      Started by Waxavi, Today, 02:10 AM
                      1 response
                      19 views
                      0 likes
                      Last Post NinjaTrader_LuisH  
                      Working...
                      X