How to Backtest a TradingView Strategy: Complete Beginner's Guide

Last updated: 19 October 2026

Backtest results Win rate54% Profit F.1.6 Max DD-8% Equity curve

Backtesting a TradingView strategy means running your Pine Script rules on old price data to see how they would have performed, before you risk real money. This beginner's guide shows how to backtest a TradingView strategy step by step: how to load a Pine Script strategy, choose historical data, read the Strategy Tester numbers (win rate, profit factor, drawdown), avoid the common traps, and then re-test the same strategy for free on PineBacktest.

Quick answerTo backtest a TradingView strategy: (1) write or copy a Pine Script strategy(), (2) add it to a chart, (3) pick the symbol, timeframe and date range, (4) set realistic commission, slippage and position size, (5) read the report, and (6) confirm the result on a second data set. A backtest shows how a strategy behaved in the past. It does not predict the future.

What is backtesting in TradingView?

Backtesting is the process of applying trading rules to historical candles and recording every trade the rules would have made. TradingView does this with strategies, which are Pine Script programs that use strategy.entry(), strategy.exit() and strategy.close() to open and close simulated trades. An indicator only draws on the chart. A strategy places simulated orders and produces a performance report. TradingView's own help centre describes this report as showing an equity chart plus metrics such as Total P&L, Max drawdown, Profitable trades and Profit factor, and a full list of trades (TradingView Help Center).

TradingView has renamed and reorganised this panel over time. Many guides call it the Strategy Tester, and newer versions label it the strategy report. The idea is the same: it lives at the bottom of the chart and summarises what the strategy did.

1Paste yourPine Script2Pick data& timeframe3Set dates,costs, size4Run and readthe report

Step 1: Get a Pine Script strategy

You can write your own or start from a public script. A minimal example is a moving-average crossover that buys when a fast average crosses above a slow one and exits when it crosses back:

//@version=5
strategy("SMA Cross", overlay=true, initial_capital=100000,
     default_qty_type=strategy.percent_of_equity, default_qty_value=100,
     commission_type=strategy.commission.percent, commission_value=0.05)

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")

The first line, strategy(...), is what makes it a strategy and not an indicator. It also sets the starting capital, the position size and the commission, which matter a lot (see Step 4).

Step 2: Add it to a TradingView chart

Open a chart, open the Pine Editor, paste the script and add it to the chart. TradingView's help page explains that a strategy can also be picked from the Indicators menu, and that only one strategy can run on a chart at a time (TradingView Help Center). If the script has errors, the editor shows them with line numbers. Fix those first.

Step 3: Choose the symbol, timeframe and date range

Your result depends heavily on what you test it on:

How much history you can load in TradingView depends on your plan and the symbol, so check what is available for your account. Deep Backtesting, a setting that unlocks a symbol's fuller price history, is described by TradingView as a premium-plan feature (TradingView Help Center).

Step 4: Set realistic costs, slippage and position size

This is the step beginners skip, and it is the main reason backtests look better than live trading. Every real trade pays a commission and usually suffers slippage, meaning you get a slightly worse price than the one on the chart. A strategy that makes a tiny profit per trade can turn into a loss once costs are added. Always set:

Step 5: Read the results the right way

Do not look at net profit alone. These are the numbers to read together:

Common backtesting mistakes to avoid

Backtest your Pine Script strategy free on PineBacktest

A second opinion on a different data source is one of the best ways to check a strategy. PineBacktest is a free Pine Script backtesting tool: you paste a TradingView strategy, pick a dataset and timeframe, and get the trades, equity curve and drawdown. Here is how to use it:

  1. Open the PineBacktest tester and paste your Pine Script strategy into the editor.
  2. Choose a dataset (Nifty, BankNifty or one of five forex pairs: EURUSD, GBPUSD, USDJPY, AUDUSD and EURJPY) and a timeframe.
  3. Pick the From and To dates. The date pickers only allow days that exist in the chosen file.
  4. Set your initial capital, position size, commission and slippage.
  5. Press run, then read the statistics, equity curve and list of trades.

The tool also checks for look-ahead behaviour and builds higher timeframes only by aggregating the 1-minute candles, which helps you avoid the most common way a backtest fools you. Open the tester and try the SMA example above, then change one input at a time and watch how the result moves.

Expect small differencesResults on PineBacktest can differ from TradingView, because the candles come from a different data source and the two engines may fill orders slightly differently. Use it as an independent check on the logic of your strategy, not as a promise of identical numbers.

A simple checklist before you trust a backtest

Frequently asked questions

How do I backtest a strategy on TradingView for free?

Add a Pine Script strategy to a chart and open the strategy report at the bottom. A free TradingView account lets you run strategies, but the amount of history and some features depend on your plan. You can also paste the same strategy into PineBacktest, which is free.

What is the difference between the TradingView Strategy Tester and Pine Script backtesting?

Pine Script is the language you write the rules in. The Strategy Tester (the strategy report) is the panel that runs those rules on historical candles and shows the results.

How accurate is a TradingView backtest?

It is only as accurate as its data and assumptions. Missing costs, slippage, repainting or too little data can make a backtest much better than real trading. Treat it as a filter that removes bad ideas, not proof that an idea works.

What is a good profit factor and win rate?

There is no universal number. Many traders look for a profit factor comfortably above 1 after costs, on enough trades, with a drawdown they can tolerate. A high win rate with large losses is still a losing strategy.

Can I backtest on 1-minute data?

Yes. PineBacktest uses 1-minute candles and can aggregate them to higher timeframes, so you can test intraday strategies on the same data at different timeframes.

Can I backtest a strategy that uses multiple timeframes?

Yes, if the script requests higher-timeframe data correctly. Be careful: badly written multi-timeframe code is a common cause of repainting.

This article is educational and is not financial advice. Past performance does not guarantee future results, and trading can lose you money. TradingView's interface and plan features change, so check TradingView's current documentation for details.

← Back to all articlesTry the backtester

More to read

Fake profit videos and repainted strategies: how to spot them before you lose moneyQuotex OTC pairs: what they are and when they are available