Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unable to create instance of NinjaScript

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

    Unable to create instance of NinjaScript

    I created six indicators in Ninjascript Editor that I later moved into a common subfolder of my NT8 Indicator, using the windows 10 folder hierarchy. They only appear there and in a subfolder in NinjaScript Editor/Indicators/mysubfolder. They do not appear system wide in Ninjatrader so do not appear in the subfolder by the same name that appears in the Indicators window. I get the Error dialog whenever I try to open a chart's indicator window that tells me "Unable to create instance of NinjaScript 'NinjaTrader.NinjaScript.Indicators.[thesubfolder.the indicator name]'. Most likely either the implementation no longer exists, there is no default constructor defined, the default constructor does not work correctly, or the 'OnStateChange' implementation for State=SetDefaults is flawed; Exception has been thrown by the target of an invocation." I get that six times in a row, once for each of those indicators before the indicator window will open.

    When the indicator window does open it shows three other indicators in the systemwide subfolder but not the six I want there that are causing this error. Each of the three and the six indicators has as its namespace line: namespace NinjaTrader.NinjaScript.Indicators.Mysubfolder. Why aren't the six and why does each throw an exception.

    #2
    Hello ProfitPilgrim,

    Thank you for the post.

    I wanted to clarify the steps you followed, you noted

    I later moved into a common subfolder of my NT8 Indicator, using the windows 10 folder hierarchy.
    Did you manually move the files outside of NinjaTrader and later modify the namespace? If so this may be part of the problem as the platform expects you to do all of the modifications directly in the NinjaScript editor. Can you confirm how you did the changes before we continue further?

    Also are you currently able to open each of these indicators in the NinjaScript editor and compile them? If any manual changes were made, the NinjaScript generated code at the bottom of each file may not have been updated. You may try just manually recompiling each indicator to "refresh" it and then restart NinjaTrader before testing again.


    I look forward to being of further assistance.

    Comment


      #3
      Thanks Jesse. to answer question one -- yes. Because I could not figure out within the Ninjascript editor how to move indicators from the Ninjascript Editor Indicators folder into a ninjascript editor/Indicators/mysubfolder I attempted to do it externally. How do I move them within Ninjascript editor?

      To answer question two -- yes I can compile fine. Recompiling and restarting haven't helped.

      Comment


        #4
        Hello ProfitPilgrim,

        To move files in the editor you just need to drag and drop the file on the folder you want it to be moved into. If the folder is not visible, the list will scroll when the mouse reaches the top or bottom of the list. You can also create folders in the editor by right-clicking on the parent folder "indicators".

        Are the 6 indicators linked in any way or are these all separate items? If these are seperate and do not depend on each other the best plan of action would likely be to exclude 5 of the 6 indicators and work on getting one of them working as that will likely highlight the problem in the other 5.

        Based on the description so far, I would be unsure what else could be causing the problem at this poiint without further reviewing the file.

        Depending on the complexity of your script, this could also be caused by using "using" statements or public properties that include type converters that no longer point to the correct namespace.

        If you are able to provide one of the scripts that is not working, we could work together on that to see what the cause is. Otherwise, I would suggest to revert the specific changes you made and move the items back to the main indicators folder. This would allow you to get back to a "working" state where you could test dragging the indicator to the folder to make sure that works. As noted the complexity can matter in some cases, without the full details I cant say that dragging the file to the folder will be the complete solution here but may make a difference.

        I look forward to being of further assistance.

        Comment


          #5
          Thanks Jesse I excluded all but 1 of 6 then deleted that 1 then recreated it as a new indicator and got the same error. Because I renamed these indicators once and it warned renaming may cause recompile errors I wonder if the problem traces to that. How do I clear NT so I can create these indicators afresh without the error? BTW, I am not able to drag custom indicators that appear in the main area of ninjascript editor indicators into a subfolder of the Indicator folder there. Could you re-explain how to do that?

          Comment


            #6
            Hello ProfitPilgrim,

            Here is a short GIF of dragging the indicator to a folder. You just have to make a folder and then click and drag/drop the file onto the folder. https://i.imgur.com/MtWBceN.gifv

            If you are still getting an error after recreating the indicator, it is very likely due to some code you are using in that indicator or naming. Can you provide the steps you used when you got the error this time? Did you paste any code into the indicator or was this a clean indicator?

            To remove the items you can exclude them or remove them using the NinjaScript editor's Right-click menu from the file browser. You can also manually remove the .cs files from the Documents\NinjaTrader 8\bin\Custom\Indicators folder. You will need to compile after making these changes.

            If you have some specific code that you are trying to use in the indicator that produces the error, we could review that together.


            I look forward to being of further assistance.

            Comment


              #7
              I discovered that the errors stopped when I removed vendor licensing code. I've contacted vendor licensing for a solution. Thanks Jesse for the faithful support.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              558 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              324 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              546 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              547 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X