🍂 Autumn Savings 🍂 Autumn Savings 20% OFF Sitewide – Up to 50% OFF Select Products View Promotions Ends in Wednesday, October 21 🏆 Compare Trade Copiers →
Support

How to Resolve NinjaScript Errors

By Affordable Indicators· December 12, 2024·5 min read
How to Resolve NinjaScript Errors

NinjaTrader compiles every NinjaScript file on your PC together, so a single file with a programming error blocks all of them. Until it is fixed, NinjaTrader will not import, update or remove add-ons, and you cannot create or edit strategies. This guide shows how to find the file causing it and how to clear the most common errors.

You will usually see one of these messages:

  • “Import failed. This NinjaScript Archive File may contain duplicate method names that already exist on your PC, modify a method signature that other scripts were dependent on, or be missing a required file on either your PC or in the import archive.”
  • “You have custom NinjaScript files on your PC that have programming errors. These errors must be resolved before you can import a NinjaScript Archive File.”
  • “Remove failed. You have custom NinjaScript files on your PC that have programming errors. These errors must be resolved before removing a NinjaScript assembly.”
  • “NinjaTrader must be in a compilable state to create or edit Strategies. Please use the NinjaScript editor to resolve compilation errors.”
  • “Unhandled exception: Could not find a part of the path ‘X/NinjaTrader 8/tmp/Import/Backup.”

Errors While Importing or Updating an Indicator

If an import fails, installing the files by hand almost always works. Follow every step in order:

  1. Open the download: double-click the zip file in File Explorer.
  2. Copy the .cs and .dll files out of the zip onto your desktop.
  3. Move them into NinjaTrader’s Custom folder:
    • Open Documents > NinjaTrader 8 > bin > Custom.
    • Drag the .cs and .dll files from your desktop into that folder. If you are updating, choose Yes to replace the existing files.
    • Put them directly in the Custom folder, not in a folder inside it.
  4. Restart NinjaTrader.
  5. Check that it worked: open a chart, right-click it, choose Indicators and look for the indicator in the list.

Note: you do not need to import the indicator again afterwards. These steps install it.

Microsoft OneDrive is the most common cause of NinjaScript errors. If your NinjaTrader 8 folder sits in a location OneDrive manages, start with our guide:

Resolving NinjaTrader Desktop Issues With Microsoft OneDrive

NinjaTrader compiles all of your indicators and strategies in one pass instead of one at a time, which is why one broken file holds up the rest. The usual causes are an add-on whose reference to a .dll file is missing, a reference that still points at an old file location, or two copies of the same file that define the same thing twice.

Find the Compile Error That Is Blocking NinjaTrader

If you already know the error code, skip to it below. If not, find it like this:

  1. In the NinjaTrader Control Center, open New > NinjaScript Editor. It can take a few seconds to appear.
  2. Right-click anywhere in the editor and choose Compile (or press F5).
  3. Watch the bottom-left corner: a loading icon shows while it compiles. If it finishes with a chime and no errors are listed, your NinjaScript compiles cleanly and your add-ons work normally.
  4. Otherwise the errors are listed in orange at the bottom of the editor. Each one names the file, the error code and a description. These must be fixed, or the file excluded (see below), before you can import or remove add-ons, and some add-ons will not work correctly until then.

An error line names the file, the code and the problem, for example:

ExampleAssembly.cs CS0006 Metadata file 'ExampleAssembly.dll' could not be found

Common Compile Errors and How to Fix Them

Start with the errors below. Clearing them often clears the rest of the list too.

CS0006 – “Metadata file ‘example.dll’ could not be found”

What it means: an add-on refers to a .dll file that NinjaTrader cannot find on your PC.

How to fix it:

  1. Right-click inside the NinjaScript Editor and choose References.
  2. Select the reference to the .dll named in the error.
  3. Click Remove.
  4. Click OK and compile again.

NinjaTrader’s video walks through it: Metadata File Not Found

CS0246 – “The type or namespace name ‘exampleassembly’ could not be found (are you missing a using directive or an assembly reference?)”

What it means: NinjaTrader is looking for a reference to a .dll file that it cannot locate.

How to fix it:

  1. Right-click inside the NinjaScript Editor and choose References.
  2. Click Add.
  3. Browse to the .dll for the file named in the error and click Open.
  4. Click OK and compile again.

This also clears the CS0118 error that often appears just below CS0246. NinjaTrader’s video: Missing Assembly or Reference

CS0234 – “The type or namespace name ‘exampleindicator’ does not exist in the namespace ‘examplelocation’ (are you missing an assembly reference?)”

What it means: one of NinjaTrader’s own built-in indicators is missing from Documents > NinjaTrader 8 > bin > Custom > Indicators, or a file there is corrupt.

How to fix it:

  1. Close NinjaTrader.
  2. Open the Windows Control Panel from the Start menu. The Windows Settings app does not have this option.
  3. Go to Programs > Programs and Features.
  4. Select NinjaTrader in the list and click Repair. This replaces missing or damaged NinjaTrader files without changing your settings.
  5. Restart NinjaTrader and compile again.

NinjaTrader’s video: Resolving the Indicator is Missing or Corrupted Message

Exclude the File With the Error From Compilation

If an error points at an add-on you do not need right now, you can leave its file out of the compile instead of fixing it, so the rest of your NinjaScript compiles and imports work again:

  1. Compile in the NinjaScript Editor and note the file named in the orange error at the bottom of the window.
  2. On the right side of the NinjaScript Editor, double-click the folder for that object type (for example, Indicators) to expand it.
  3. Left-click the file to select it, then right-click it.
  4. Select Exclude From Compilation, then compile again. From the same menu, Open lets you debug the file instead, and Remove deletes it.

An excluded add-on is not available in NinjaTrader until you include it in compilation again.

Resolving Uncommon Compile Errors

For any other error code, NinjaTrader’s Desktop Help Guide lists every documented compile error and its fix: Compile Error Codes

If the code is not listed there, contact the developer of the add-on named in the orange error. If the error is in a NinjaScript you wrote yourself and it is not documented, contact NinjaTrader support, who can pass it to their NinjaScript Engineering team.

If the error names one of our add-ons, contact our support team and we will help you clear it.

Trade with the right tools. Our NinjaTrader trade copier mirrors your trades across every prop-firm account, and our chart trader tools put one-click order management on your chart — lifetime licenses, free updates, live chat support.
See the trade copier →
Buy with Confidence · 🛡️ 8,000+ customers · ⭐ 4.8 Trustpilot · 🏆 18 years programming experience