I managed to upgrade my desktop to C# 9.0 somehow when I installed Microsoft Visual Studio. I assume this happened when .Net 9.0 was installed with that program.
Now several of the core NT indicators (trendlines, channel lines, COT etc) don’t work anymore. When I compile any indicator, NT gives me numerous errors for 100s of indicators (“NinjaScript Feature ‘target-typed object creation’ is not available in C# 8.0. Please use language version 9.0 or greater”). I assume some of the C# 8.0 code base is now no longer valid in C# 9.0.
I actually didn’t think this could happen since NT runs its own compiler. Has anyone experienced this issue? Is there a way to re-install C# 8.0 so that the indicator code works? Can I “wall-off” NT so it goes back to using .Net 8.0?
Have you tried upgrading to the latest version to see if it resolves your issue? The latest version 8.1.6 supports C#13 but still stuck at .NET 4.8. Note, that some people are having slow loading issues with it. I think for some reason, maybe your NinjaTrader may be using an older compiler instead of an updated one. NinjaTrader 8.1.4 supports C#9.
It turns out one of my Ninjascripts was corrupted (an old one that I didn’t use from an add-in I had long forgotten about). Every time I compiled, it would throw 100s of these crazy errors. I’m guessing that when I upgraded Visual Studio, it made the script incompatible but who knows. It might have just been time for it to go.
The only way I found this out was by doing a clean re-install of the new version of NinjaTrader. Then, when I went to restore my backup, it told me all my backup files were corrupted, too. After I stopped throwing up, I reloaded each of my NinjaScripts one by one from the backup of my backup (yes, this was a huge pain). Then I re-imported my Add-ons. Halfway through, I loaded the corrupt Add-on, and it promptly shut down NT. When I had reloaded all of my other scripts and Add-ons, NT compiled just fine, and everything returned to normal.
The takeaways from two days of work on this fix are:
Don’t keep old add-ons that you don’t use hanging around. Every once in a while, go through your indicators and make sure you are still using them. I still had add-ons from when NT first introduced v8.0 that I hadn’t used in years.
Don’t assume your back up will be there for you. Make sure you have a backup of your Ninjascripts, Workspaces and Templates. Go to Documents–>NinjaTrader 8–>bin—>Custom–>Indicators and just copy this whole folder to Dropbox every time you make a change. In fact, just copy the whole “NinjaTrader 8” folder every once in a while. If I hadn’t done that, I would have been stuck rebuilding from scratch.
If you get an error reloading your backup, you can uncheck some of the categories (Ninjscripts, Workspaces, Configuration Files, etc) and load one at a time so you can isolate the problem.
Even though my back-ups failed, make sure you do it regularly and keep the historical back ups. If a backup gets corrupted, you want to be able to go back in time to figure out when it happened. I had a year of backups, but even that wasn’t enough since the Add-on had been there for years. Although it didn’t help, I realized that the problem must have been in one of the older Ninjascripts or Add-ons.