This article outlines common NinjaScript compile errors that may appear when importing a third-party add-on, removing a NinjaScript Assembly, using the Strategy Builder, or updating the NinjaTrader Desktop app.
The most common reason for issues NinjaScript Errors is related to Microsoft OneDrive. If your NinjaTrader files are stored in a location that is managed by Microsoft OneDrive, you might want to start by looking at our article on this:
Resolving NinjaTrader Desktop Platform Issues With Microsoft OneDrive
To optimize runtime performance, NinjaTrader Desktop compiles all indicators and strategies simultaneously, rather than compiling them individually.
Compile errors most often appear when a third-party add-on is missing a Reference to its location, there is an old Reference specifying an out-of-date file location, or there are duplicate files with duplicate definitions.
Examples of these error messages include:
- “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 Indicator
Solution for the following Errors:
“This NinjaScript Archive File may contain duplicate method names that already exist on your PC…”
“Unhandled exception: Could not find a part of the path ‘X/NinjaTrader 8/tmp/Import/Backup.”
If you already have the software installed and recieve this error when importing the new version follow Resolution 1. If this is your first time installing the software, refer to Resolution 2.
Resolution 1 (Updating Indicator):
- Open NinjaTrader Control Center > Tools > Remove NinjaScript Assembly > Select the Software name you were trying to update> Remove
- From NinjaTrader Control Center > Tools > Import > NinjaScript Add-On > Select download zip file > OK
- Reboot NinjaTrader
Resolution 2 (First Time Installing):
- Open the software zip file: Double-click the download zip file in File Manager.
- Pull the Files: Drag the
.cs
and.dll
files onto your desktop. - Move Files to the Correct Folder:
- Navigate to
Documents > NinjaTrader 8 > bin > Custom
. - Drag the
.cs
and.dll
files from your desktop into this folder. -
Ensure that these files are not placed in a secondary folder within the Custom directory.
- Navigate to
- Restart NinjaTrader: Reboot NinjaTrader to apply the changes.
- Note: Once the steps are complete, there’s no need to reimport the indicator; it will already be added.
- Verify the Indicator has been added:
- Open a chart in NinjaTrader.
- Right-click on the chart, then select Indicators.
- Check if the indicator has been successfully added.
Determine which Compile Errors are Impacting NinjaTrader Desktop
If you’re aware of the error message you encountered, you can skip this section and locate the specific error below. If you’re unsure of the error message, follow these steps to identify it.
To begin troubleshooting compile errors, open the NinjaScript Editor from the Control Center > New dropdown. This window may take a few moments to load before appearing on the screen. Once open, right-click in the background and choose “Compile” from the menu that appears.
- Compile errors shown in orange must be resolved before importing or removing any add-ons. Some add-ons may not function correctly until these errors are fixed.
- A loading symbol in the bottom-left of the NinjaScript Editor appears during compilation. If no errors appear after it disappears and you hear a chime, it indicates there are no errors, and you can use and edit your add-ons normally.
Common Compile Errors and Resolutions
If any compile errors in orange appear at the bottom of the NinjaScript Editor, start by addressing the following key errors first, as resolving these will likely clear the remaining errors automatically.
CS0006 – “Metadata file “example.dll ” could not be found.
Cause: A *.dll file is being referenced, but NinjaTrader Desktop is unable to find it.
Resolution:
- Right-click within the NinjaScript Editor window and select References
- Locate and select the reference to the *.dll file mentioned in the Error
- Click remove to remove the reference
- Click OK and recompile
A YouTube video outlining this process can be viewed here: 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?)”
Cause: NinjaTrader Desktop is searching for a reference to a *.dll file that it is unable to locate.
Resolution:
- Right-click within the NinjaScript Editor window and select References
- Click Add
- Locate the *.dll file for the file mentioned in the error
- Click Open to add the reference
- Click OK and recompile
These steps will also resolve the CS0118 error that appears below CS0246. A YouTube video outlining this process can be viewed here: Missing Assembly or Reference
CS0234 – “The type or namespace name ‘exampleindicator’ does not exist in the namespace ‘examplelocation‘ (are you missing an assembly reference?)”
Cause: A system indicator is missing from the NinjaTrader 8 > bin > Custom > Indicator folder on your machine’s hard drive, or a corrupt file is currently present.
Resolution:
- Shut down NinjaTrader Desktop
- Select the Windows Start Menu > search for and open the “Control Panel” (this cannot be accomplished through the Windows Settings page).
- Select Programs > Programs and Features
- Highlight NinjaTrader in the list of installed programs
- Click “Repair” which will replace any missing or corrupted files without affecting any of your custom settings
- Finally, restart NinjaTrader and recompile
A YouTube video outlining this process can be viewed here: Resolving the Indicator is Missing or Corrupted Message
Resolving Uncommon Compile Errors
If you are receiving a compile error in the NinjaScript Editor that is not listed above, a full list of documented NinjaScript Compile Errors and their resolutions may be found here in our NinjaTrader Desktop Help Guide – Compile Error Codes
If the error(s) you are receiving are not listed on that page, please reach out to the developer/vendor of the add-on identified in the orange compile error for further troubleshooting.
If any undocumented compile errors are occurring on a NinjaScript you coded yourself, please let us know, and we can forward your request to our NinjaScript Engineering team for further support.