TradingView (Pine Script)

Using the Strategy Tester

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.

The fastest place to backtest is inside HorizonAI. Hunt or iterate in the Horizon platform (results in seconds) and only bring code to TradingView after you export. If you're talking to Pine Script directly, use the Chrome extension. Use this page when you'd rather drive TradingView's own tester by hand.

Already on the chart?

This page assumes the strategy is already added. If it isn't, follow Run on TradingView first (Copy Code → Pine Editor → Add to chart), then come back here.

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) Open Strategy Tester

  • Click the Strategy Tester tab (it appears next to Pine Editor once a strategy is on the chart).
  • 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 Code, 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. It must be declared with strategy(...). See Run on TradingView after regenerating as a strategy.

Compile errors? See Pine Script Warnings, or paste the error into HorizonAI.

Poor results? Use realistic commission and slippage in the strategy Settings. Common backtesting mistakes.