Backtesting on TradingView: the Strategy Tester and its limits

TradingView’s Strategy Tester is the fastest way most traders ever backtest an idea — write a few lines of Pine Script, hit a button, and see an equity curve and stats in seconds. It is genuinely useful for quickly killing bad ideas and visualising trades on the chart. But it also flatters strategies in ways that quietly mislead beginners: optimistic fills, limited history on lower timeframes, and the infamous repainting trap. This guide shows how to backtest on TradingView properly, how to read the report, the realism limits to respect, and when to graduate to a Python backtest.

On this page
  1. The Strategy Tester
  2. How to backtest
  3. Reading the report
  4. The realism limits
  5. The repainting trap
  6. When to move to Python
  7. FAQ

The TradingView Strategy Tester

TradingView lets you write a strategy in Pine Script using strategy.entry and strategy.close calls. Add it to a chart and the built-in Strategy Tester runs it over the visible history, producing a performance summary, a list of trades, and an equity curve — all overlaid on the chart so you can see exactly where each trade fired.

How to backtest a strategy

pine · sma_strategy.pine//@version=5
strategy("SMA Cross", overlay=true)
fast = ta.sma(close, 20)
slow = ta.sma(close, 50)
if ta.crossover(fast, slow)
    strategy.entry("long", strategy.long)
if ta.crossunder(fast, slow)
    strategy.close("long")

Set commission and slippage in the strategy properties — leaving them at zero is the most common way beginners fool themselves. Mirror the methodology in how to backtest a strategy.

Reading the performance report

The report shows net profit, percent profitable, profit factor, max drawdown and number of trades. Do not stop at net profit — check the drawdown you would have had to stomach, the profit factor (gross profit ÷ gross loss; above 1.5 is healthy), and especially the trade count, since a strategy with twenty trades proves nothing.

The realism limits to respect

Optimistic by default

The Strategy Tester fills at the bar’s price with no order-book depth, so on illiquid symbols it ignores real slippage. Lower timeframes have limited history on most plans, shrinking your sample. And it assumes your order always fills — fine on liquid majors, dangerously optimistic on thin markets. Always set realistic commission and slippage before trusting a number.

The repainting trap

Some indicators repaint — they look perfect in hindsight because they use data that was not available in real time (e.g. referencing the current bar’s close before it closed). A repainting strategy shows an incredible backtest and fails instantly live. Use confirmed values (close[1], barstate.isconfirmed) and be deeply suspicious of any too-perfect curve.

When to move to a Python backtest

TradingView is excellent for rapid idea-testing and visualisation. Once an idea survives it, validate seriously: a Python backtest with real OHLCV (see data sources and ccxt), explicit fees and slippage, and walk-forward out-of-sample testing — or run it on our backtester. Use TradingView to find ideas; use a rigorous backtest to trust them.

Not financial advice. This content is educational. Automated and algorithmic trading carries a real risk of financial loss. Never trade money you cannot afford to lose. Review the SEC investor.gov and CFTC resources before trading.

Frequently asked questions

How do you backtest on TradingView?

Write a strategy in Pine Script using strategy.entry and strategy.close, add it to a chart, and the built-in Strategy Tester runs it over the visible history. It produces a performance report, a trade list and an equity curve overlaid on the chart. Crucially, set realistic commission and slippage in the strategy properties before trusting any result.

Is TradingView backtesting accurate?

It is useful but optimistic by default. The Strategy Tester fills at the bar price with no order-book depth, so it ignores real slippage on illiquid symbols, has limited history on lower timeframes, and assumes orders always fill. It is excellent for quickly killing bad ideas, but a serious strategy should be validated with a rigorous Python backtest including realistic costs.

What is repainting in TradingView?

Repainting is when an indicator or strategy looks perfect in hindsight because it uses data that was not available in real time, such as referencing the current bar before it closed. A repainting strategy shows an incredible backtest and fails instantly live. Use confirmed values like close[1] or barstate.isconfirmed, and distrust any too-perfect equity curve.

Should I use TradingView or Python to backtest?

Use both, in sequence. TradingView is the fastest way to test and visualise an idea and kill bad ones quickly. Once an idea survives it, validate seriously with a Python backtest using real OHLCV data, explicit fees and slippage, and walk-forward out-of-sample testing. Use TradingView to find ideas and a rigorous backtest to trust them.

MB

Mustafa Bilgic

Algorithmic trading practitioner · Founder, AITradingBot.us

Mustafa builds and backtests automated trading systems and writes about them without the hype. Every tool on this site is free and runs entirely in your browser.