Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategies calling indicators it doesn't use

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

    Strategies calling indicators it doesn't use

    I've been getting messages in the Control Center's Log page, something about "Indicator CCI (or whatever): Error on calling 'OnBarUpdate' method on bar such and such. You are accessing an index with a value that is invalid since it is out-of-range."

    No I'm not. I'm not using CCI at all in my strategy. I placed a break point in CCI's OnBarUpdate just to see if Ninjatrader is making things up and apparently it isn't. The thing is, Ninjatrader is accusing me of doing something I didn't even do. In fact, you can put breakpoints in OnBarUpdate for most any other indicator and apparently it will stop there too. (I'm finding CCI, ADX, DMI plus two others that I wrote are all being called for some reason. I've only checked for a few minutes but I'll bet more are being called if I took the time to find out.)

    The screen shot shows Ninjatrader.Core is calling these indicators. But why? There is no logical reason for NT to do that, it seems to me, while running my strategy which doesn't even use them.
    Attached Files

    #2
    Is another workspace open in the back ground?

    I'd try a new clean workspace and close the previous.

    Is this in replay? I wonder if this is related to nt consuming cpu cycles to the point of going super slow.

    Comment


      #3
      Hello traderpards,

      In general, runtime errors would not appear for a script unless the script is being loaded in memory.

      OnStateChange() is called for SetDefaults on all scripts any time the Indicator window is opened. But this would not happen when running a strategy in the Strategy Analyzer if the script does not call the CCI.

      Has the CCI been modified on your computer? (Have you imported any scripts that may have overwritten the CCI)

      I agree with sledge that you should test for the behavior without a saved workspace loading.

      Does this error appear when the backtest button is clicked in the Strategy Analyzer?
      Does the message appear when loading charts or a workspace?
      Does the message appear when opening the Indicators window?

      If the errors only appear when the backtest button is hit in the Strategy Analyzer, may we test your script?

      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


        #4
        Yes, there is another workspace open in the background. But I'm not using any of those indicators there either. This isn't in Market Replay - it's in a live environment.

        I

        Comment


          #5
          Hello traderpards,

          Start NinjaTrader without any saved workspaces including the main workspace.
          • Shut down NinjaTrader
          • Navigate to (My) Documents\NinjaTrader 7\workspaces
          • Delete the file named "_Workspaces.XML".
          • After deleting this file, restart NinjaTrader which should startup without any workspaces.
          • Once NinjaTrader has started on just the control center, please open a new chart and test for the issue.

            *Please note this will not delete your workspace however the new blank workspace will be named Untitled1. If you have a workspace already named Untitled1 however you will not want to save the workspace when exiting NinjaTrader, otherwise it will overwrite it.


          The Strategy Analyzer is used for backtesting and uses historical data. This would be used when connected to a real-time data feed and not with the Market Replay.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Neither the CCI, DMI or the ADX has been modified on my computer and there is no chance any of those have been overwritten. Can you even do that with read-only indicators?

            Did I mention Backtest? No, this is from a live environment. I'm not sure if it does it in Backtest or not. We can cross that bridge when we come to it. I'll let you investigate Backtest.

            You don't need my scripts. You can use Sample MA Crossover. Here is how you reproduce this:
            1. Log in to your favorite data feed.
            2. Open a new chart with any instrument, any bar type.
            3. Load the Sample MA Crossover.
            4. Launch Visual Studio and load Ninjatrader.Custom.csproj.
            5. Click Debug - Attach to process and select Ninjatrader 8.
            6. Open the ADX and the CCI.
            7. In both of those CS files, scroll down to OnBarUpdate and set a break point. (F9)
            8. Sit and wait for it to happen.

            I just tried it with the Sample MA Crossover and it hit the CCI break point in a matter of seconds.

            Comment


              #7
              Hello traderpards,

              Likely, you are running into an issue with Visual Studio.

              Are you able to run the script without errors in NinjaTrader (without attaching a debug process to VS)?
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Actually I'm running into an issue of the previous author of this thing instantiating every Tom, **** and Harry indicator he could think of for every Tom, **** and Harry strategy in it, whether he needed to or not, and he really didn't. I've spent the last two hours undoing all of that. No wonder this thing ran like a dog.

                It's late in the trading day but I've had a few bars change over and no break points are getting hit any longer. Sorry - I didn't realize it because who the hell does that??

                Comment


                  #9
                  Hi traderpards,

                  I'm not quite able to understand your last post.

                  Are you able to run the script without error in NinjaTrader without Visual Studio attached for debugging?
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Yes... "no break points are getting hit."

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    670 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    379 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    111 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    575 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    582 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X