You may come across various situations where your NinjaScript files will not compile. This can include situations such as:
- You are trying to import a NinjaScript Archive File and you receive an error such as "You have custom NinjaScript files on your PC that have programming errors..."
- You are new to NinjaScript development and somehow your files will no longer compile
Because importing NinjaScript files requires compilation of your entire NinjaScript library you will first need to resolve the errors to allow for a successful compilation.
1st Step in Resolving Errors:
To delete the erroneous file:
- Backup NinjaScript files (File > Utilities > Backup, ensure that "NinjaScript Files" is checked and then press the "Run Backup" button) in version 6.5 or later
- Open any indicator via the menu Tools > Edit NinjaScript > Indicator
- Press the "F5" key on your keyboard to compile your NinjaScript library. A list of errors will appear at the bottom of the NinjaScript Editor along with the file name where each error is located.
- Determine if you no longer need the NinjaScript file with the errors. If you no longer need it, skip to step 9.
- Double click on the error message to open the NinjaScript with the errors. Try to resolve the error and recompile by pressing the "F5" key.
- If the error still exists in this file, "comment out" some or all of the content in the OnBarUpdate() method and recompile by pressing the "F5" key
- If errors still exist in this file, "comment out" some or all of the content in the Initialize() method and recompile by pressing the "F5" key
- If errors still exist in this file, "comment out" any properties that in the "Properties" region that may be causing the problems and recompile by pressing the "F5" key
- If errors still exist in this file, try to delete the indicator/strategy (See "To delete the erroneous file" instructions below)
- If another NinjaScript file references a file you wish to delete, open the file that references the file you wish to delete and "comment out" or delete the reference
- Repeat steps 2 through 10 for every NinjaScript that still has errors
How to "comment out" code:
- Tools > Edit NinjaScript > "Select either Indicator or Strategy depending on what type of file you want to delete
- Highlight the NinjaScript file you wish to delete and press the "Delete" button
- If another NinjaScript file references the file you wish to delete, you must first remove the reference to the file you wish to delete, see step 10 above
- Press the "Cancel" button to close the NinjaScript file dialog window
Commenting out code simply means to identify code which will be treated as a comment (not processed) as opposed to actual program code. This can be done by adding "//" in front of each line of code. Below is an example.
2nd Step in Resolving Errors:
double myDouble = 5;
// double myDouble = 5;
If the above procedure does not resolve all errors, you may need to reinstall NinjaTrader.
- Backup any files you wish to back up (File > Utilities > Backup version 6.5 or later)
- Shut down NinjaTrader
- Uninstall NinjaTrader from the windows Control Panel Add/Remove Programs
- Manually delete the folder My Documents\<NinjaTrader Installation Folder>
- Clear you temporary internet files in your internet browser (browser cache)
- Reinstall the latest version of NinjaTrader from our website