Export to TradingView
Learn how to export your Backtrex strategy as Pine Script v5 code, import it into TradingView, and verify signal parity.
Overview
Backtrex can export any strategy as Pine Script v5 code, ready to paste into TradingView. The export guarantees less than 2% divergence between Backtrex backtest results and TradingView results.
How to Export
- Open the strategy you want to export
- Click the Export button in the strategy builder header
- A code preview modal appears with the generated Pine Script
- Review the code to verify it matches your strategy
- Click Copy to copy the code to your clipboard, or Download to save as a
.pinefile
Importing into TradingView
- Open TradingView and navigate to the Pine Editor (bottom panel)
- Click Open > New blank indicator (or New blank strategy for backtesting)
- Paste the exported code
- Click Add to chart
- Your strategy will appear on the chart with entry/exit markers
What Gets Exported
The Pine Script output includes:
- All indicator calculations: MA, RSI, MACD, Bollinger Bands, and all SMC blocks
- Entry and exit conditions: Your complete logic chain
- Anti-repainting safeguards:
barstate.isconfirmedchecks and[1]offsets - Stop-loss and take-profit levels: If configured in your strategy
- Multi-timeframe references: Using
request.security()for cross-timeframe indicators
Parity Guarantee
Backtrex targets less than 2% divergence between its backtest results and TradingView results. Small differences can occur due to:
- Rounding differences in floating-point calculations
- Slight variations in data feeds between Backtrex and your TradingView broker
- Bar timing differences in multi-timeframe calculations
To verify parity:
- Export and apply the strategy on TradingView
- Use the same asset and date range
- Compare total return, number of trades, and win rate
- Differences should be minimal (less than 2%)
Anti-Repainting in Export
The exported Pine Script includes built-in anti-repainting protections:
- All signal evaluations wrapped in
barstate.isconfirmedchecks - Price references use
[1]offset (previous confirmed bar) - No use of
close(current bar) for signal generation
This means the Pine Script strategy on TradingView will behave identically to the Backtrex backtest.
Tips
- Export after you are satisfied with backtest results
- Test the exported script on TradingView to verify signal alignment
- The exported code is read-only by design. If you need to modify the strategy, make changes in Backtrex and re-export
- Save your exported scripts as TradingView indicators for easy access