Backtesting in HorizonAI
HorizonAI can run any Pine Script strategy it writes for you as a real backtest inside your own TradingView account. A free Chrome extension does the work in your browser, against your own TradingView session — click Backtest and the full report, equity curve, and trade list come back in the chat, where the AI can read them and suggest improvements.
What it is
Because Pine Script only runs inside TradingView, the backtest runs in your browser, in your TradingView account — not on our servers. The HorizonAI extension takes the strategy the AI generated, injects it into the Pine Editor, runs TradingView's Strategy Tester, and reads the results back into the chat panel: net profit, profit factor, win rate, max drawdown, an equity curve, and a trade-by-trade breakdown.
Nothing is saved to your TradingView account — the strategy is injected, run, and cleared. Your charts are left exactly as they were.
What you'll need
- Google Chrome (or a Chromium browser that supports Chrome extensions).
- A TradingView account — the free tier is fine.
- A Pro or Elite HorizonAI plan.
- The HorizonAI TV Backtester extension, installed and signed in (steps below).
1) Install the Chrome extension
- Open the HorizonAI TV Backtester on the Chrome Web Store — or click the TradingView Extension link in the app's sidebar, under Support.
- Click Add to Chrome, then confirm the permissions.
- Pin the extension so you can see its status light: click the puzzle-piece icon in Chrome's toolbar and pin Horizon TV Backtester.
2) Sign in to the extension
The extension has no login of its own — it reads the session you're already signed into on HorizonAI.
- Open app.horizontrading.ai and sign in with your Pro or Elite account.
- Click the extension icon. It should show Connected, along with your plan and whether a TradingView tab is ready.
3) Open a TradingView chart
Open TradingView in another tab and load any chart. The extension uses your most-recently-active TradingView tab to run the test, so just having one open is enough — you don't need to set the symbol or timeframe yourself. HorizonAI drives the chart to match the symbol and timeframe you pick in the Backtest form.
4) Build a Pine Script strategy
- In an app.horizontrading.ai chat, make sure the script type is set to Pine Script.
- Describe the strategy you want, e.g. "SMA 20/50 crossover strategy on BTCUSD with a fixed 2% stop." The AI writes it and shows it in the Code panel.
5) Open the Backtest tab and run
- In the right-side panel, switch from Code to the Backtest tab.
- Pick a symbol and timeframe.
- Click Run.
The extension injects the strategy into your TradingView tab, compiles it, runs the Strategy Tester, and scrapes the results — usually in a couple of seconds. Keep the TradingView tab open while it runs.
6) Read the results
When the run finishes, the panel shows two views:
- Report — net profit, profit factor, percent profitable, max drawdown, winning/losing counts, average and largest win/loss, a long vs short breakdown, and an equity curve.
- Trades — a sortable table of every trade: entry and exit time and price, direction, quantity, P&L in dollars and percent, and cumulative profit.
The AI can read the report alongside your code, so you can ask things like "why is the drawdown so high?" or "tighten the stop and try again" and iterate right there.
Limits & fine print
- Who can run it: Pro and Elite plans only.
- Where it runs: in your own browser, in your own TradingView account — your TradingView tab must stay open during the run.
- Date range & properties: the backtest uses TradingView's default range and default Strategy Properties (initial capital, commission, slippage). Adjust them on the chart in TradingView if you need a specific setup.
- Ephemeral: the strategy is never saved to your Pine library — it's injected, run, and removed.
Troubleshooting
- "Install the Horizon TradingView extension" — the app can't reach the extension. Make sure it's installed, then open app.horizontrading.ai signed in as Pro/Elite and click Recheck.
- Extension disabled after an update — a new version that adds permissions is paused by Chrome until you re-approve it. Open
chrome://extensions, find Horizon TV Backtester, and re-enable it. - "No TradingView tab" — open a chart on tradingview.com and try again.
- Backtest tab is greyed out — your script is an indicator, not a strategy. Ask the AI to convert it to a
strategy(...). - "Your Pine didn't compile" — the strategy has a Pine error. Ask the AI to "fix the compile error," or check Common Pine Script Warnings.
When to use this vs. driving TradingView by hand
| Use the in-app backtester when… | Paste into TradingView by hand when… |
|---|---|
| You want results back in the chat so the AI can read and iterate | You want to change the date range or Strategy Properties for this run |
| You want a fast, one-click read on the AI's strategy | You want to tweak inputs with TradingView's own settings dialog |
| You're on Pro or Elite with the extension installed | You're on Starter/free, or don't want to install an extension |
See Backtest on TradingView for the manual copy-paste workflow.
Understanding Your Results
- Backtesting Metrics Explained — Profit factor, Sharpe, drawdown, expected payoff
- How to Backtest a Trading Strategy — Validation best practices
- Common Backtesting Mistakes to Avoid — Curve-fitting, look-ahead bias, and other traps
Related Guides
- Backtest on TradingView — Drive the Strategy Tester by hand
- Run Strategies on TradingView — Deploy your Pine Script
- Quickstart — Build your first strategy with HorizonAI
- How to Talk to Horizon AI — Prompt tips for better strategies
- Convert Pine Script to MT5 — Test on MetaTrader 5 instead