

Why Your Backtest Looks Different in TradingView
Nov 16 | 4 Minutes MIN | Backtesting

By
Kvants
The rules look the same, but the results do not. Your TradingView run shows a different entry, fewer trades, or a wider drawdown than your original backtest. Before you rewrite the strategy, compare the assumptions behind the two simulations.
A useful place to start is the first trade where they disagree. It turns a vague performance gap into a specific question: did the signal change, did the fill change, or did the position size change?
1. Match the inputs before comparing the outcome
Write down the exchange, exact symbol, market type, timeframe, and test dates for both runs. BTC spot and a BTC perpetual contract are different instruments. A familiar ticker alone is not enough to establish that two tests used the same data.
Use standard candles for the comparison. Then inspect the timestamps and OHLC prices around the first mismatched trade, along with the earlier candles needed to initialize the indicators. Keep the strategy parameters unchanged while you investigate.
2. Compare the signal and the fill separately
The signal is the condition that requests a trade. The fill is the price and time at which the simulator executes it. Treat them as separate events.
For a hypothetical example, suppose a long signal appears when a bar closes at 100 and the next bar opens at 102. A simulation that fills at the signal close records 100. Under TradingView’s default historical market-order timing, the fill would normally occur at the following bar’s open, giving 102 in this example. The rule can agree while the entry price differs.
Open the Trades tab in TradingView’s strategy report and find that first mismatch. Record its direction, entry time, entry price, and quantity. Compare those details with the original run before looking at total return.
3. Check costs, sizing, and execution settings
Review order size, commission, slippage, and fill timing in the strategy settings. TradingView expresses its native slippage setting in ticks. A value recorded in basis points elsewhere needs an appropriate conversion; copying the number directly does not preserve its meaning.
Also check whether a modeled cost is already included in the exported script. Adding it again can count the same cost twice. Keep an untouched copy of the export so that later edits are easy to trace.
If entry times match but profit and loss differ, compare position quantities and costs next. For stop and limit orders, check the execution assumptions rather than assuming that touching a price guarantees the same fill in every simulator.
4. Fix one mismatch at a time
Keep a short comparison log: the first divergent trade, the suspected cause, the setting you changed, and the result after rerunning. Change one variable at a time. Otherwise, a closer equity curve can hide several offsetting errors.
Explaining the first divergence is more useful than adjusting settings until the final returns happen to match. Once that trade makes sense, move to the next mismatch and repeat the process.
Put your next strategy to the test with Kvants
Turn a trading idea into rules you can examine. With Kvants, describe your thesis in plain English, review the signals and risk rules, and backtest with modeled costs before moving to paper trading or export.
Backtest and paper-trading results are hypothetical and do not guarantee future performance.
Technical reference: TradingView’s official Pine Script strategy documentation.

Read more


















