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

  1. Open the strategy you want to export
  2. Click the Export button in the strategy builder header
  3. A code preview modal appears with the generated Pine Script
  4. Review the code to verify it matches your strategy
  5. Click Copy to copy the code to your clipboard, or Download to save as a .pine file

Importing into TradingView

  1. Open TradingView and navigate to the Pine Editor (bottom panel)
  2. Click Open > New blank indicator (or New blank strategy for backtesting)
  3. Paste the exported code
  4. Click Add to chart
  5. 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.isconfirmed checks 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:

  1. Export and apply the strategy on TradingView
  2. Use the same asset and date range
  3. Compare total return, number of trades, and win rate
  4. 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.isconfirmed checks
  • 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