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:
- “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.”
Determining which Compile Errors are Impacting NinjaTrader Desktop
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.