Backtesting guide

How to backtest on TradingView

To backtest on TradingView, add a Pine Script strategy to a standard price chart, set its capital, size, costs and test period, then inspect the strategy report. Basic accounts can start with core backtesting; history, report features and exports depend on the plan. Results describe simulated trades under chosen assumptions.

Read the practical guide

Key Takeaways

  • Use a strategy with order rules. Adding an indicator alone does not create Strategy Tester trades.
  • Record the symbol, timeframe, session, dates, code version and Properties before comparing results.
  • Inspect individual fills before interpreting net profit, drawdown or win rate.
  • Export trade records for further analysis; a CSV cannot repair biased signals or unrealistic fills.

1. Add a strategy to a standard chart

Choose the exchange symbol and timeframe you intend to study, then use standard candles or bars. In Indicators, metrics and strategies, select a built-in or published strategy. For your own code, open Pine Editor, save the script and select Add to chart. A strategy uses strategy() and order commands; indicator() alone cannot populate the trade report.

  • Open the bottom strategy report panel, often called Strategy Tester, and select the intended strategy if several are on the chart.
  • Check that trade markers and report rows appear. If there are no trades, inspect runtime errors, entry conditions, order size, available capital and date filters.
  • Keep a copy of the source and inputs. A community strategy may change, and a screenshot alone does not preserve its rules.

2. Set capital, size and execution costs

Open the strategy settings and inspect Properties. Set initial capital, account currency, order size and margin assumptions for the instrument. A script can supply its own defaults or explicit order quantities, so verify the resulting trade size in the report rather than assuming the Properties value controls every order.

  • Commission: choose percent, cash per contract or cash per order to match the fee convention. A percentage value of 0.05 means 0.05%, not 5%. Include both entry and exit costs when checking a completed trade.
  • Slippage: TradingView applies a fixed tick adjustment to market and stop fills. Choose a baseline from execution evidence and compare an adverse scenario. A single fixed value cannot reproduce changing spread, liquidity or market impact.
  • Limit orders: inspect fill verification and whether the test assumes a fill on a touch or requires price to trade beyond the limit. Historical bars do not describe queue position.
  • Keep the rules and dates fixed while changing costs. Save net profit, drawdown and trade count for each scenario; do not select the fee assumption that produces the best result.

3. Choose dates and preserve a later test period

Record the actual first and last dates in the report. Ordinary backtests use available chart history; moving or zooming the viewport is not a reliable entry-date filter. Use the strategy's date inputs where supplied, or add explicit time conditions to the order logic. Deep Backtesting can use a selected interval beyond loaded chart bars, subject to available history and account access.

  • Specify the date timezone and what happens to an open position at the end. Blocking new entries does not close a position or cancel pending orders.
  • Keep enough earlier data for indicator warm-up. A different history start can change recursive calculations such as an EMA.
  • Choose a development period and leave a later period untouched until the rules are fixed. Retuning on that later period makes it part of development.
  • Do not change timeframe solely to obtain more history: that changes the signals and the trading hypothesis. No universal trade-count threshold proves reliability.

4. Read the trades before the headline return

Current TradingView documentation describes Metrics and Trades tabs; older interfaces use Overview, Performance Summary and List of Trades. Start with several trade rows and locate them on the chart. Check the signal, order creation time, fill time, quantity, price and exit reason against the intended rules.

  • A signal at a bar close need not fill at that close. With default bar-close calculation, a new market order normally fills at the next available tick, typically the next bar open.
  • Read net profit alongside drawdown, trade count, average trade and profit factor. A high win rate can coexist with large losses.
  • Run-up measures favorable movement during a trade; drawdown measures adverse movement. They are different from the final realized profit or loss.
  • Check whether a few trades dominate the result. Compare long and short trades, time periods, and a buy-and-hold benchmark without treating outperformance alone as proof of risk-adjusted alpha.

5. Audit fills, chart prices and repainting

A broker emulator applies a price-path model to historical bars. Bar Magnifier uses available lower-timeframe data to refine intrabar fills, with coverage limits. It does not reconstruct every historical transaction, queue or live fill. If both stop and target are reachable within one bar, inspect how changing the fill model affects that trade.

  • Prefer standard charts. Heikin Ashi can use standard OHLC for fills through its strategy setting, but signal calculations can still use synthetic chart prices; Renko and other synthetic charts need separate scrutiny.
  • For confirmed higher-timeframe values, the documented pattern offsets the requested expression by one bar and uses lookahead_on. Unoffset lookahead_on can leak future values into history. lookahead_off alone does not guarantee a non-repainting request.
  • Review calculation and order-processing settings before changing them. Enabling calc_on_every_tick does not recreate missing historical ticks, and allowing close fills does not guarantee a broker could fill at that price.

6. Export trades and reconcile the CSV analysis

Export the trade list from the strategy report, not the summary metrics or chart OHLC data. TradingView's support page describes a CSV download from List of Trades; current strategy documentation also describes an XLSX report export. Use the export available in your interface and check plan access before relying on this workflow.

  • If you receive XLSX, open the workbook and save the trade-list sheet as CSV in a spreadsheet app. Renaming the extension does not convert it. Preserve the headers, timestamps, decimal separators and entry/exit rows.
  • Upload a compatible TradingView trade CSV to Backtest Deep Report. Confirm the imported closed-trade count and total profit against TradingView before reading additional metrics. A new export layout may require column mapping or may be unsupported.
  • Match initial capital, currency, date range and treatment of open trades. Keep the original export and its strategy settings together so differences can be investigated.
  • Use distributions, rolling metrics and Monte Carlo resampling to examine the recorded sample. Resampling trades cannot establish future probabilities, detect lookahead bias in the original code or reproduce shared capital across a portfolio.

What free TradingView backtesting includes

You can begin with a Basic account and a strategy available to that account. Core historical simulation is separate from access to advanced report metrics, export options, deeper history and intrabar detail. Check the current TradingView plan comparison for the feature you need; free testing does not mean every report feature or published strategy is free.

  • A bar limit is not a fixed number of days. The covered period depends on timeframe, market session, data availability and gaps.
  • Deep Backtesting extends the calculation beyond loaded chart history. It does not add missing market data or turn bars into historical ticks.
  • Bar Replay is a separate workflow for stepping through chart history. It is not a substitute for defining reproducible strategy order rules.

Direct Pineify workflow

Build the strategy, then examine its trade records

Pine Script AI Coding Agent can help turn explicit trading rules into editable strategy code. Backtest Deep Report analyzes compatible TradingView trade CSV files after you have reviewed the original simulation.

Pine Script AI Coding Agent

Describe entry, exit, sizing, date boundaries and costs for a reviewable Pine Script strategy.

Create a backtestable strategy
Backtest Deep Report

Inspect distributions, drawdowns and resampled outcomes from compatible trade records.

Analyze backtest trade CSV

Boundary: TradingView supplies the chart data and runs the simulation. Generated code needs syntax and behavior checks; CSV analysis cannot correct biased signals, missing costs or unrealistic fills.

This page is educational and does not provide investment advice. Backtests are hypothetical, depend on their data and assumptions, and do not guarantee future results. Trading can result in substantial loss.

Frequently Asked Questions