How to export an AlphaPrime strategy to TradingView, step by step
Open the strategy's source code in the Performance report, export it for TradingView, 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 TradingView, export its Pine Script v6 source code from the Performance report, import it into TradingView, 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, TradingView 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 file 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 TradingView, then click Export file to save it, or Copy code.
- TradingView strategies don't need the AlphaPrime library, so there is no extra step.
How do you import it into TradingView?
Import the strategy, make sure it compiles, then add it to a chart.
- Open the Pine Editor in TradingView.
- Paste the code into the Pine Editor.
- Add the strategy to the chart.
Which settings must match the backtest?
The header of the exported code lists what the backtest used. Set the same in TradingView:
- Commission and slippage are already written into strategy(): don't change them again in the properties
- Instrument, bar period, big point value, tick size and number of contracts
- The number of warm-up bars
- Turn on Deep Backtesting and match the start and end dates
- The chart session must match the data used in AlphaPrime
A different time zone or session moves every bar, and missing costs make the platform's results look better than the backtest.
How do you check TradingView against AlphaPrime before going live?
Run the strategy in TradingView 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. TradingView strategies don't use the AlphaPrime library at all.
Can I edit the exported code?
Yes. It is plain-text Pine Script v6 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. TradingView: https://www.tradingview.com/

