Skip to content

Use generated code in NinjaTrader

Xen returns editable NinjaScript C# source. The code block includes actions to copy the source, download it as a .cs file, run Build Check and verify the original requirements.

Before importing the file, check that its class name, file name and namespace match the intended NinjaScript type. Strategies normally belong in NinjaTrader.NinjaScript.Strategies; indicators normally belong in NinjaTrader.NinjaScript.Indicators.

Open NinjaTrader's NinjaScript Editor and create or import the appropriate script. Replace the template source when copying code manually, then compile it in NinjaTrader. If the generated file has dependencies on another custom script or assembly, those dependencies must also be present.

Build Check catches many C# and NinjaTrader assembly errors before this point, but NinjaTrader remains the final authority. It can detect platform lifecycle errors and runtime conditions that a server-side compilation cannot reproduce.

Test before live use

After compilation, open the script's properties and review every input. Run strategies in Strategy Analyzer and then in a simulation account with representative market data. Confirm entries, exits, order handling, session boundaries and risk controls. For indicators, compare plots and signals across several instruments, bar types and market conditions.

Generated code is a development starting point, not a guarantee of trading performance or operational safety. Do not enable a strategy on a live account until you understand the source and have completed your own testing.

For general platform installation information, see the NinjaTrader installation guide.