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 useindicator(...)
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.
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.
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.
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.