NinjaTrader AI Strategy Builder Blocked by NinjaScript Errors? How to Fix It

You open New > AI Strategy Builder in NinjaTrader 8.1.9.0, a box says “Checking for NinjaScript compile errors…” and then NinjaTrader stops with this message:
“You have custom NinjaScript files on your PC that have programming errors. These errors must be resolved before you can use the AI Strategy Builder.”
Nothing is wrong with the AI Strategy Builder, and nothing is wrong with the strategy you were about to describe. The message means one of the NinjaScript files already on your PC does not compile, and NinjaTrader will not open the builder until it does. The fix is to find that file and either repair it or move it out of the way.
Why the AI Strategy Builder checks your NinjaScript first
NinjaTrader Desktop (NinjaTrader 8) compiles every custom NinjaScript file on your PC into one build: your own indicators and strategies, and every add-on you have imported. One file with an error stops that whole build.
The AI Strategy Builder writes the strategy it creates into that same build, compiles it there and then runs the backtest. If the build is already broken, the new strategy could not compile either. So NinjaTrader checks first, and NinjaTrader’s own AI Strategy Builder guide lists the compile check as the step before you begin.
The same check guards other parts of NinjaTrader. With the same broken file you will also see the message when you import a NinjaScript Archive File, export one, or remove a NinjaScript assembly. If your imports have been failing too, it is the same cause. You may also see a window called Uncompilable NinjaScript, which says NinjaScripts must be in a compilable state and offers an Open Editor button. That is the same check as well.
What usually breaks the build
The file at fault is rarely one you are working on today. These are the usual causes:
- An old indicator or strategy you no longer use. Something imported years ago that does not compile any more, sitting in the folder where you have forgotten about it.
- A copy of a file. A Windows ” – Copy” file, a OneDrive conflict copy named after your PC, or a Mac ” 2″ copy. Two copies define the same indicator twice, and the build stops.
- A half-installed add-on. Some of its files arrived and others did not, so what did arrive cannot compile.
- A file that uses something you removed. For example, a strategy that calls an indicator you have since deleted.
Find the file by hand
Before you move anything, copy your Documents\NinjaTrader 8\bin\Custom folder somewhere safe, outside the NinjaTrader 8 folder.
- In the Control Center, open New > NinjaScript Editor.
- Press F5 to compile. The errors appear in the list at the bottom of the editor. The NinjaScript File column names the file, and a double-click opens it at the line.
- Start with the first file named. One broken file often causes errors in the files that use it, so fixing the first one can clear the rest.
- If it is your own file, fix the line and press F5 again.
- If it is an indicator or strategy you do not need, take it out of the build: close NinjaTrader, move the .cs file out of Documents\NinjaTrader 8\bin\Custom\Indicators (or Strategies) to a folder outside the NinjaTrader 8 folder, then open NinjaTrader and press F5 in the NinjaScript Editor again.
- When F5 compiles with no errors, open New > AI Strategy Builder again.
One trap: NinjaTrader’s Remove NinjaScript Assembly is blocked by the same check, so you cannot use it to remove a broken add-on while the build is broken. Moving the file that breaks the build is usually the way out. If it belongs to an add-on you still want, import that add-on again afterwards, or ask its developer for a version that compiles on your NinjaTrader.
Or let Fix & Optimize find it, free
Fix & Optimize (formerly the Repair Tool) is our tool for NinjaTrader Desktop. Fixing your NinjaScript errors with it is free, for good. A free account is all it needs: confirm your email and add your name, country and ZIP. No card.
- It backs up first. It zips your Custom folder to your Desktop before it changes anything, and it stops if that backup fails.
- It clears the usual causes. It moves copied files aside (” – Copy”, OneDrive and Mac copies, copied .dll files), re-creates NinjaTrader’s import folder if it has gone missing, and cleans up references to files that no longer exist.
- It reads NinjaTrader’s own compile. If a file still breaks the build after those fixes, it names the file and offers to set it aside, together with any file that depends on it. It asks you before it sets a file aside.
- It never deletes anything. What it moves goes into a dated folder on your Desktop, with a list of what moved and why, so you can put a file back once it is fixed.
- It knows what not to touch. It never sets aside NinjaTrader’s own files or the files of our own products, and if the errors are in NinjaTrader’s own files it does not offer to set anything aside. It does not rewrite code either: if the error is in a file you wrote, the NinjaScript Editor’s error list shows you the line to fix.
The goal is for NinjaTrader’s own compile to finish with no errors, which is what the AI Strategy Builder checks before it starts. After the run, open the NinjaScript Editor and press F5: when it compiles with no errors, open the AI Strategy Builder again.
It runs on the Windows PC or VPS where you run NinjaTrader. See how it works and fix your NinjaScript errors free.
Questions
Is the AI Strategy Builder broken?
No. The check is NinjaTrader making sure your NinjaScript compiles, so the strategy it writes for you can compile and run a backtest. Once F5 in the NinjaScript Editor compiles with no errors, your NinjaScript passes that check.
Do I have to delete my indicators?
No. Moving the file that breaks the build out of the Custom folder is enough. Keep it somewhere safe and put it back when it has been fixed or its developer has sent a version that compiles.
I get the same message when I import an indicator.
It is the same check. Once the build compiles, imports work again too.
Which NinjaTrader version has the AI Strategy Builder?
It arrived as a beta in NinjaTrader 8.1.9.0, in English only, and NinjaTrader is rolling it out in phases.
I still see errors after moving a file.
Press F5 again and read the list from the top: the next file named is the next one to look at. For other NinjaScript error messages, see How to Resolve NinjaScript Errors.
Affordable Indicators, Inc. is not affiliated with or endorsed by NinjaTrader. NinjaTrader, NinjaScript and AI Strategy Builder are NinjaTrader’s names, and NinjaTrader’s own help guide is the authority on how its AI Strategy Builder works.