TradingView Pine Script — Browser-Based Strategy Backtesting
TradingView is a web-based charting platform with a built-in Strategy Tester and its own scripting language, Pine Script. No installation, no data management, no setup — open a browser, write a strategy, and backtest it on any chart. The Strategy Tester is available on all tiers, including the free plan.
Pine Script: The Language
Pine Script (currently v6) is a domain-specific language designed exclusively for trading indicators and strategies. It’s the easiest scripting language in the trading platform space — most strategies can be written in 20-100 lines.
Key characteristics:
- Python-like syntax with type inference
- Built-in functions for all common indicators (SMA, EMA, RSI, MACD, Bollinger Bands, etc.)
strategy.entry(),strategy.exit(),strategy.close()for order managementrequest.security()for multi-timeframe analysis- Arrays, matrices, maps, and user-defined types
- No external library imports — fully self-contained
- Max 500 local scopes; server-side execution time limits apply
Example — simple moving average crossover:
//@version=6
strategy("MA Crossover", overlay=true)
fast = ta.sma(close, 10)
slow = ta.sma(close, 50)
if ta.crossover(fast, slow)
strategy.entry("Long", strategy.long)
if ta.crossunder(fast, slow)
strategy.close("Long")
That’s a complete, runnable strategy. Pine Script’s strength is this kind of rapid prototyping — you can go from idea to backtest in minutes.
Strategy Tester Features
The Strategy Tester tab appears below the chart when you run a strategy() script. It provides:
- Performance Summary — net profit, gross profit/loss, max drawdown, Sharpe ratio, Sortino ratio, profit factor, win rate, average trade
- List of Trades — every entry/exit with P&L, bars held, and drawdown
- Equity Curve — visual equity and drawdown chart
- Deep Backtesting — paid plans can request additional historical bars from the server for longer test periods
Order types: Market, limit, stop, stop-limit. Pyramiding is configurable (max simultaneous entries in the same direction). Commission and slippage can be set per-trade (fixed or percentage).
Timeframes: 1 second to 12 months, including custom timeframes on paid plans.
What It Can’t Do
- No tick-level simulation — backtests on OHLC bars. Intra-bar order fills are approximated, which can produce unrealistic results when entries and exits happen on the same bar.
- No walk-forward optimization — you can manually sweep parameters via
input()variables, but there’s no automated walk-forward engine. - No Monte Carlo simulation
- No portfolio backtesting — one instrument per strategy
- No external data import — you’re limited to TradingView’s data feeds
- No direct broker integration for automated execution from backtests (alerts can trigger webhooks as a workaround)
Pricing
Strategy Tester is available on all tiers, including free.
| Tier | Price (annual) | Indicators/Chart | Key Backtesting Impact |
|---|---|---|---|
| Free | $0 | 3 | ~5,000 bars intraday; delayed data |
| Essential | $12.95/mo | 5 | More historical bars |
| Plus | ~$24.95/mo | 10 | 4 charts/tab, 100 alerts |
| Premium | ~$49.95/mo | 25 | Pattern recognition, more data |
| Ultimate | $239.95/mo | 50 | Maximum historical data depth |
The main backtesting limitation on free tier is historical data depth — roughly 5,000 intraday bars. Paid tiers increase this significantly via Deep Backtesting.
Data Quality and Limitations
TradingView uses its own data feeds aggregated from exchanges. Quality is generally reliable for daily and above, but there are caveats:
- Intraday data depth is limited, especially on free tier
- Bar-level only — no tick data means fills are approximated within each bar
- Repainting risk — incorrect use of
request.security()can cause strategies to look better in backtests than they would trade live - Exchange-dependent — data quality varies by instrument and exchange
- Survivorship bias — delisted stocks may not appear
Supported Instruments
Virtually anything on TradingView charts: stocks (global exchanges), forex, crypto, futures, indices, bonds, CFDs, ETFs.
Pros
- Zero setup — runs in browser, no installation
- Easiest scripting language to learn for trading
- Massive community: 100,000+ public scripts, 60M+ registered users
- Strategy Tester free on all tiers
- Multi-timeframe data access via
request.security() - Rapid prototyping — idea to backtest in minutes
- Active development; Pine Script updated regularly
Cons
- Limited historical data, especially on free tier
- OHLC bar-level only — no tick simulation
- No walk-forward, no Monte Carlo, no portfolio testing
- Cannot import external data
- Pine Script locked to TradingView ecosystem
- Server-side execution limits can constrain complex strategies
- Repainting risks with careless
request.security()usage
Who Is This For?
TradingView backtesting is best for traders who want to quickly validate strategy ideas without deep programming knowledge. If you need tick-level accuracy, walk-forward optimization, or portfolio testing, look at NinjaTrader, AmiBroker, or code-based frameworks instead.