Running NinjaScript on NinjaTrader 8
HorizonAI writes and converts NinjaScript — the C#-based language that powers NinjaTrader 8. This page explains what NinjaScript is, what HorizonAI does for you inside the app, and the short loop you follow to get your code running on your own charts in NinjaTrader.
What is NinjaScript?
NinjaScript is the programming language of NinjaTrader 8, a popular desktop platform for futures and forex traders. It's built on C#, and it comes in two flavours:
- Indicators — draw studies on your chart (moving averages, RSI, custom signals).
- Strategies — place and manage trades automatically, and can be backtested.
You write NinjaScript in the NinjaScript Editor inside NinjaTrader, compile it, and it runs natively on the platform.
What HorizonAI does with NinjaScript
You can both generate NinjaScript from scratch and convert existing code into it:
- Create: on the New Script page, set the language toggle to NinjaScript, describe your idea, and the AI writes it.
- Convert: on the Converter, NinjaScript (labelled NinjaTrader 8) is part of the full any-to-any matrix — turn Pine Script or MQL5 into NinjaScript, or go the other way. Uploads accept
.csfiles. - Get your code out: click Copy Code in the chat header to copy the whole script to your clipboard.
What happens in the app vs. in NinjaTrader
For NinjaScript, HorizonAI is where you write, refine, and convert the code. Everything after that — compiling, adding it to a chart, and backtesting — happens inside NinjaTrader 8, which is free to install.
So the NinjaScript loop is short:
- Generate or convert your script in HorizonAI.
- Click Copy Code.
- Paste it into the NinjaScript Editor in NinjaTrader 8 and compile.
- Add the indicator to a chart, or run the strategy in the Strategy Analyzer.
Indicator or strategy?
The AI produces whichever you ask for. If you describe a study that draws on the chart, you'll get an indicator (a class deriving from Indicator). If you describe something that enters and exits trades, you'll get a strategy (a class deriving from Strategy). NinjaTrader reads that base class when you compile and files the result in the right place automatically — you don't have to tell it which is which.
Next steps
Follow these three guides in order to go from copied code to a running script:
- Setting up NinjaTrader 8 — Install the platform and create a free simulation account
- Using the NinjaScript Editor — Paste your code, compile with F5, and add it to a chart
- Backtesting in NinjaTrader — Test a strategy in the Strategy Analyzer
Related Guides
- Quickstart — Build your first script with HorizonAI
- How to Talk to Horizon AI — Get better NinjaScript out of the AI
- Converting between languages — How the any-to-any converter works
- Visual Flow — See your Pine Script or MQL5 strategy as a node graph