Overview

Backtest on TradingView

Run your Pine Script strategy and read the Strategy Tester report

Use TradingView’s Strategy Tester to evaluate your strategy’s performance with an overview, detailed metrics, and a full list of trades.

Prerequisite: use a Strategy, not an Indicator

  • Your Pine Script must be a strategy to access TradingView’s backtester.
  • In Pine Script, strategies are declared with strategy(...) (indicators use indicator(...) and won’t show the Strategy Tester).
  • If the Strategy Tester tab does not appear after adding to chart, you’re likely running an indicator.

If you don’t see the Strategy Tester, make sure your script is a strategy (not an indicator). Regenerate as a strategy in HorizonAI, then copy it again.

1) Copy your strategy from HorizonAI

  • Finish any edits in the app and click Copy.
  • Your Pine Script strategy is now on your clipboard.

2) Open a TradingView chart

  • Open TradingView and load the chart you want to test on.
  • Choose the symbol and timeframe you’ll use for the backtest.

3) Open the Pine Editor

  • At the bottom of the TradingView interface, click Pine Editor.

4) Paste your strategy code

  • Select all existing code in the Pine Editor and delete it.
  • Paste the code you copied from HorizonAI.

5) Add to chart

  • Click Add to chart.
  • TradingView compiles the script and attaches it to your chart.

When the script is a strategy, a new tab labeled Strategy Tester appears next to Pine Editor.

6) View your backtest in Strategy Tester

  • Click the Strategy Tester tab.
  • Review the Overview for high‑level results (net profit, win rate, drawdown, etc.).
  • Open Performance Summary for detailed metrics and risk/return statistics.
  • Check List of Trades to see every entry/exit, timestamps, and P/L.

Use the chart’s date range and timeframe to change the backtest window. You can also open the strategy’s Settings (gear icon on the chart) to adjust inputs, commissions, initial capital, and more.

Iterate quickly

  • Want to tweak logic or parameters? Return to HorizonAI, adjust your prompt, click Copy, then paste and Add to chart again.
  • Rerun the backtest and compare results in the Strategy Tester.

Troubleshooting

No Strategy Tester tab? Your script is likely an indicator. Ensure the script is declared with strategy(...) and copy it again from HorizonAI.