How to export an AlphaPrime strategy to NinjaTrader 8, step by step
Open the strategy's source code in the Performance report, export it for NinjaTrader 8, import it, set the items the code's header lists, then compare trade lists on the same data before going live.
By Soren Huang · Published · updated · Editorial policy
Contents
To run a strategy from AlphaPrime (Valynox) in NinjaTrader 8, export its NinjaScript source code from the Performance report, import it into NinjaTrader 8, set the chart and strategy the way the code's header describes, and compare both trade lists on the same data before you trade it live.
What do you need before you start?
You need a strategy in the AlphaPrime strategy databank, NinjaTrader 8 installed, and the same market and history you tested on. The trial version can also view and export source code, so you can follow every step before buying.
How do you export the strategy from AlphaPrime?
Export happens in the Performance report, on the strategy's source code tab. The strategy is saved as
- In the strategy databank, double-click the strategy to open it in the Performance report.
- Open the Strategy source code tab. The left column lists the conditions and parameters; the right column shows the source code.
- Choose NinjaTrader 8, then click Export file to save it, or Copy code.
- The first time only, press Export library and import the AlphaPrime library once. The library file is AlphaPrime_NinjaTrader.zip; exported from a strategy's screen, it holds only the functions that strategy uses. Import it with Tools → Import → NinjaScript Add-On.
How do you import it into NinjaTrader 8?
Import the strategy, make sure it compiles, then add it to a chart.
- Import the AlphaPrime library first, as described above.
- Add the strategy file to NinjaScript and compile it, following NinjaTrader's official NinjaTrader 8 help guide.
- Add the strategy to a chart.
Which settings must match the backtest?
The header of the exported code lists what the backtest used. Set the same in NinjaTrader 8:
- Instrument, bars and date range
- Number of contracts, commission, point value, tick size and MaxBarsBack
- Slippage is already folded into the commission template: set the strategy's Slippage to 0
- Use the bar type and trading session the strategy was built with
- The exchange time zone is a strategy parameter
- The strategy calculates on each bar close and fills market orders at the next bar's open
A different time zone or session moves every bar, and missing costs make the platform's results look better than the backtest. Compare against the Strategy Analyzer.
How do you check NinjaTrader 8 against AlphaPrime before going live?
Run the strategy in NinjaTrader 8 on the same data and period, then compare its trade list with AlphaPrime's trade list, trade by trade.
- Use the same instrument, bar size and date range as the backtest.
- Compare entry and exit times first: a shift of one bar usually means a time zone or session difference.
- Then compare prices and costs: different fills or missing commission show up here.
- Where they differ, check the data source next: two data feeds can build slightly different bars.
The guide to trading costs in backtests: commission, slippage and the average trade explains why costs matter, and walk-forward analysis covers how a strategy is checked on data it didn't see.
What this means if you use AlphaPrime (Valynox): the exported code is plain text you can read and edit, and the platform export page lists every supported platform.
Frequently asked questions
Do I need to export the library every time?
No. For NinjaTrader 8, export and import the AlphaPrime library once; strategies exported afterwards use it.
Can I edit the exported code?
Yes. It is plain-text NinjaScript you can read and change. After an edit, compare the trade list again, because the strategy is no longer the one AlphaPrime tested.
Can the trial version export strategies?
Yes. The trial can view and export source code, so you can try the whole process before buying.
What AlphaPrime does here
AlphaPrime exports strategy source code to MultiCharts, TradingView, TradeStation and NinjaTrader; the platform export page has the list. NinjaTrader 8: https://ninjatrader.com/

