TradingView Backtesting

TradingView Bar Replay for Indicator Validation

Use TradingView Bar Replay to advance through historical bars and record when an indicator signal first becomes visible. It helps inspect delayed pivots, changing drawings, and discretionary rules. A replay does not prove that a script never repaints, reproduce every live price update, or test alert delivery. Use a Pine strategy for automated order simulation and a separate live observation session for alert behavior.

See the decision guide

Start an indicator replay and record each decision

Add the indicator to a standard candlestick chart, then open Bar Replay from the top toolbar and choose a starting bar. Use Forward for one step or Play for automatic playback. Indicators and drawings can remain on the chart when you leave replay. The procedure below is a proposed audit workflow, not a report of measured trading results.

  • Write down the exchange-qualified symbol, chart interval, session, timezone, script version, and inputs before starting.
  • Choose the test dates and entry rules before viewing their outcomes. Leave enough earlier bars for the indicator to initialize.
  • Advance one bar at a time near a signal. Record its first observable timestamp and the timestamp where its marker is plotted.
  • Capture the chart before moving on. After the session, reload and compare the same timestamps for changed values or drawings.
  • Keep rejected setups and ambiguous cases in the log. If you revise a rule, give it a new version and test a separate period.

Bar Replay, Replay Trading, and Strategy Tester answer different questions

Replay Trading adds simulated orders and performance reports to a replay session. TradingView documents market positions, limit, stop and stop-limit orders, bracket controls, and capital and commission settings. You can export its Performance and List of trades reports. This is a separate mode from Paper Trading; keep a copy of the session records rather than relying on them as a permanent journal.

  • A plotted indicator arrow is not an order. Automated testing requires a strategy script with explicit order rules.
  • Bar Magnifier uses lower-timeframe data for strategy fill simulation. It does not turn ordinary Bar Replay into a complete live tick history or remove lookahead mistakes.
  • For a manual close-confirmed entry rule, state whether you assume a next-bar open fill. Record costs separately; there is no universal slippage allowance that fits every market.
WorkflowUseful outputWhat it does not establish
Indicator in Bar ReplayA record of when markers and values become observableAutomated order fills or successful alert delivery
Replay TradingA report of simulated trades you placed during replayThe results of automatically running a Pine strategy
Strategy TesterOrders and metrics produced by a strategy script and broker emulatorLive execution quality or freedom from lookahead bias
Live observation and alert testingActual realtime signal and notification timestampsA guarantee that future signals or fills will behave identically

Check the available replay history

TradingView reports that daily replay uses available daily history. For intraday time-based data, Essential starts with six months at one minute and Plus with one year; their windows scale with the interval in minutes. Premium and professional plans access the stored time-based history for the symbol, which can still be shorter than the requested period. Use the earliest available replay date to check your actual dataset.

  • The current data-availability page lists Tick Replay on Ultimate for up to the most recent seven days. That is distinct from ordinary time-based bar stepping.
  • TradingView help pages are not fully aligned on tick support: the general setup article still excludes tick-based charts. Check the dedicated data page and the Replay options available to your account.
  • A missing earlier date can be a data or plan limit. Changing indicator code cannot create missing market history.

Inspect repainting mechanisms, not just the finished chart

Repainting includes differences between historical and realtime calculations; it is broader than deliberate use of future data. A delayed pivot can be valid if its confirmation delay is disclosed. Ordinary bar stepping cannot reconstruct every transient value that existed inside a historical candle, so a quiet replay is not a certificate of non-repainting behavior.

  • The confirmed HTF value is intentionally delayed. Using close without the offset together with lookahead_on leaks future HTF values into historical bars.
  • Using close[1] with lookahead_off has different historical update timing; it is not an interchangeable version of the documented confirmed-HTF recipe.
  • This example addresses one data request. Other parts of a script can still use changing data or draw into the past.
MechanismWhat to recordCode review or follow-up
Pivot with five right-hand barsThe pivot bar and the later bar where confirmation first appearsPlot on the confirmation bar, or disclose any backward plotting offset.
Unconfirmed chart-bar valuesWhether the signal is intended to require the closing updateUse barstate.isconfirmed for a close-based rule and observe realtime behavior separately.
Higher-timeframe requestThe requested interval and when a new value becomes availableFor confirmed HTF values, pair an expression offset with lookahead_on and enforce a higher requested interval.
Confirmed previous daily close, for intraday time-based charts (Pine Script v6)pinescript
//@version=6
indicator("Confirmed Daily Close for Replay", overlay = true)

if not timeframe.isintraday
    runtime.error("Use an intraday time-based chart below one day.")

// The expression offset and lookahead setting work together.
// This uses the previous completed daily bar, not the developing daily close.
previousDailyClose = request.security(syminfo.tickerid, "1D", close[1], lookahead = barmerge.lookahead_on)
plot(previousDailyClose, "Previous confirmed daily close", color = color.teal, linewidth = 2)

Use a signal marker that has one clear confirmation rule

This small EMA example places a marker only when a crossover is present on a confirmed chart bar. It has no simulated entries, stops, targets, or profitability claim. In replay, inspect the markers; after leaving replay, create an alert separately to check live delivery. Historical bars are confirmed, so the confirmation gate alone cannot demonstrate how an open live candle behaved.

Close-confirmed signal markers and alert conditions (Pine Script v6)pinescript
//@version=6
indicator("Replay Signal Observation", overlay = true)

fastLength = input.int(9, "Fast EMA length", minval = 1)
slowLength = input.int(21, "Slow EMA length", minval = 1)
fastEma = ta.ema(close, fastLength)
slowEma = ta.ema(close, slowLength)

crossUp = ta.crossover(fastEma, slowEma)
crossDown = ta.crossunder(fastEma, slowEma)
buySignal = crossUp and barstate.isconfirmed
sellSignal = crossDown and barstate.isconfirmed

plot(fastEma, "Fast EMA", color = color.blue)
plot(slowEma, "Slow EMA", color = color.orange)
plotshape(buySignal, title = "Confirmed up cross", style = shape.triangleup, location = location.belowbar, color = color.teal, text = "UP", size = size.small)
plotshape(sellSignal, title = "Confirmed down cross", style = shape.triangledown, location = location.abovebar, color = color.maroon, text = "DN", size = size.small)

// These declare choices for a separately created live alert.
// Advancing replay does not send historical alert notifications.
alertcondition(buySignal, "Confirmed up cross", "Confirmed EMA up cross on {{ticker}} {{interval}}")
alertcondition(sellSignal, "Confirmed down cross", "Confirmed EMA down cross on {{ticker}} {{interval}}")

Keep an observation log before calculating performance

Record signal availability separately from the trade outcome. The fields below are a blank recording specification, not actual trades. Use timestamps as the main reference because bar_index can change when the loaded history changes. When a bar touches both a target and a stop, mark the order sequence as unresolved unless the available data and your fill model resolve it.

  • Use a spreadsheet or journal for the observations. Pineify Trading Journal supports manual trade logging and CSV import; keep replay trades clearly identified as simulations.
  • If you use a TradingView export, check its columns against the journal import format. This page does not establish a direct Replay Trading import integration.
  • Turn specific mismatches into code requests: for example, plot a pivot at confirmation time or replace an unconfirmed daily filter with the previous daily value.
  • Evaluate revised rules on a separate period. A fixed count such as 50 or 100 trades cannot, by itself, establish statistical reliability.
Log fieldWhat to saveWhy it matters
Run settingsSymbol, session, timezone, interval, dates, script version and inputsReproduce the observation.
Signal availabilityFirst visible timestamp and marker timestampSeparate delayed confirmation from retrospective placement.
DecisionTaken, skipped or ambiguous, with the rule appliedPreserve losing and rejected setups.
Fill assumptionOrder type, modeled fill price, quantity and costsKeep signal price separate from execution price.
EvidenceScreenshot or saved values, plus the result after reloadCompare what was observable with the finished chart.
OutcomeExit rule, result and unresolved price sequenceAvoid treating unknown fill order as a win.
Where Pineify fits

Trading Journal

Record simulated trades manually and keep the rules and observations alongside your review. Check the CSV format before importing external records.

Also useful: Pine Script AI Coding Agent. Bring the script and a timestamped replay mismatch to the coding agent. Request a rule revision and syntax check, then compare the chart behavior again.

Explore Trading Journal

Frequently asked questions

Educational programming guidance, not investment advice. Replay observations and simulated results do not establish future returns or live execution quality. The examples illustrate signal logic and have not been tested here for trading performance.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.