How to Backtest on TradingView: Bar Replay and Strategy Tester
TradingView offers two different ways to investigate a historical trading rule: step through a chart with Bar Replay, or run a Pine strategy and inspect its simulated trade report. Choose the method that matches the rule, and record the assumptions before looking at results.

Define the Test
Specify the symbol and exchange, interval, session, date range, entries, exits, order timing, sizing and costs. A statement such as “buy a convincing breakout” needs an operational definition before two reviewers can reproduce it.
Check actual data availability for the selected instrument. Chart bars, replay depth and Deep Backtesting have different limits; Premium should not be described as unlimited history. A bar count cannot be converted to years without knowing the interval and trading sessions.
Use Bar Replay for Sequential Review
Open Bar Replay, choose a supported starting point and advance without revealing later bars. The official replay instructions explain the controls and limitations. Record each decision when its evidence becomes available.
TradingView also documents trading on historical data. Use the replay trading controls where available; do not assume a connected broker's ordinary order ticket has switched to historical simulation merely because the chart is replaying.
Keep a decision log with the entry condition, intended order, stop, exit and costs. Record skipped setups as well as trades. A manual review can evaluate discretionary rules, but remembering the later outcome contaminates the exercise.
Use a Strategy for Repeatable Rules
Add a Pine strategy that explicitly defines orders. An indicator with buy/sell markers is not automatically a strategy. Inspect the resulting strategy report and individual trades, then compare a few entries and exits with the written specification.
The strategy documentation explains the broker emulator, order timing and costs. Confirm the settings used by the actual script rather than assuming every trade executes at the signal close. Synthetic chart prices need particular care; use an appropriate standard-price test for execution assumptions.
Read Metrics Together
| Metric | Meaning | Common misinterpretation |
|---|---|---|
| Net profit | Net outcome under the test's assumptions | Evidence of future profitability |
| Maximum drawdown | Largest measured peak-to-trough equity decline | Simply the longest losing streak |
| Win rate | Share of closed trades classified as winners | A measure of profit without loss sizes |
| Profit factor | Gross profit divided by absolute gross loss | A universal pass/fail score |
Inspect the trade list and concentration of returns. One unusually large winner or a small sample can dominate a summary. Use costs appropriate to the market; there is no universal slippage amount in pips that applies to every instrument.
Keep Selection and Evaluation Separate
Choose parameters on an earlier segment, then apply them unchanged to a later segment. In a walk-forward design, repeat that sequence while preserving the order of information. Do not revise the settings after seeing a test segment and still call that segment untouched.
A successful out-of-sample period is useful evidence, not a guarantee. Changes in liquidity, execution, market behavior and repeated model selection can still affect later results. The number of years or trades needed depends on the hypothesis and event frequency.
Compare the Methods
Bar Replay helps inspect decisions sequentially. A strategy can evaluate explicit rules consistently across a dataset. Neither method supplies missing information or validates rules that use future data. Use manual checks to verify the automated implementation rather than treating the report as authoritative merely because it is numerical.
Can I test without writing code?
You can review a rule with Bar Replay or use an existing strategy whose logic and assumptions you understand. An automated report still depends on the strategy's code.
Does Premium provide unlimited history?
No. Check the current limits and the data available for the instrument. Ordinary chart testing, replay and Deep Backtesting are distinct.
Is a high win rate enough?
No. Inspect average wins and losses, drawdown, costs and sample size. A high win rate can coexist with a net loss.
Can I do this on mobile?
Check the controls available in the current app version. Use the web or desktop environment when the needed editor, report or settings are unavailable; do not assume identical interfaces.

