Pine Script

TradingView Backtest: 5 Numbers That Mislead

2026-10-20·11 min read

You paste a Pine Script onto your TradingView chart — Pine Script is the built-in scripting language for indicators and strategies. You hit Add Alert but can't find Any alert() function call. The Strategy Tester panel is grayed out. Backtesting won't run, you can't see win rate or net profit.

What nobody tells you upfront: only scripts starting with strategy(...) get a Strategy Tester. Those starting with indicator(...) don't. This has nothing to do with your plan or how much you pay — it's Pine Script's Rule Zero from the official documentation, yet almost no one mentions it.

strategy(...)
Gets the Strategy Tester panel
indicator(...)
Draws charts only, no backtesting
Check the first line
Tells whether a script can be backtested

This article doesn't cover "how to design a strategy" — that's a different topic. We've already written[Three Pitfalls of Retail Quantitative Trading: Overfitting, Survivorship Bias, and Lookahead Bias](/blog/en/quant-for-retail). This piece does three things: get the backtest running, understand the numbers on the panel, and lay out the five default values in strategy() that secretly change results against the official documentation.

Scope and Verification Baseline for This Article
All default values and behaviors of Pine Script built-in functions are cross-referenced against the strategy() page of the Pine Script v6 Language Reference Manual (verification date: September 15, 2026). Platform feature availability by plan is cross-referenced against the plan comparison table on tradingview.com/pricing; paid tiers may change at any time, so we recommend checking the current version yourself before proceeding.

Gap One: Is Your Script an indicator or a strategy?

Pine scripts come in only two flavors: indicator(...) does visual rendering only, while strategy(...) places simulated orders and generates performance tables. The official documentation states this plainly, yet AI-generated Pine scripts often mix them up — you ask it to "write me an RSI reversal strategy" and the first line it gives you is indicator("RSI Reversal"). Such a script won't even open the Strategy Tester.

The fastest way to tell: look at the first executable function in the file. Only strategy() gets a Strategy Tester. A single script won't have both declarations — you only need to check that one line.

QuestionAnswer
First line says indicator()?No Strategy Tester panel. To backtest, must rewrite as strategy()
First line says strategy()?Strategy Tester tab appears below the chart; click it to see the performance table
Neither (not declared)?Pine v6 requires a declaration; compilation fails directly

How to tell whether a script can be backtested (verification date: September 2026, Pine Script v6)

Changing indicator() to strategy() isn't just swapping a word — the latter adds a bunch of parameters related to capital, leverage, and commissions (we'll go through each in Section Five). But these **all have default values**. Leave them blank and Pine will still run, except the numbers it produces are TradingView's official defaults, not your actual situation.

Gap Two: Can the Basic plan run backtests? Yes, but these three things will block you.

The free Basic plan can open the Strategy Tester — you can apply a strategy() script you wrote or someone shared, see the performance numbers on the Overview tab, and view the List of Trades. This step doesn't require payment.

What usually blocks you isn't "can't open it" but these three things:

Basic (Free)Premium and above
Open Strategy Tester, view Overview numbers
Bar Magnifier (simulate fills using lower timeframe data)
Pine computation time limit20 seconds40–100 seconds
Max indicators per chart225–50
Webhook notifications (auto POST signals to other services)

Differences in backtest experience between Basic and Premium (as of September 2026, sources: tradingview.com/pricing and Pine v6 strategy() official reference)

Bar Magnifier is particularly noticeable — the official strategy() reference for the use_bar_magnifier parameter reads "Only Premium and higher-tier plans have access to this feature". Basic users who haven't paid, even if they check the box, won't get it to work.

4 OHLC points
Without Bar Magnifier, only open/high/low/close per candle
1 second / 1 minute and lower
With Bar Magnifier, uses all candles from the lower timeframe
Larger timeframe
Bigger impact — daily charts affected most, tick charts barely at all

One candle on a 1-hour chart may have already triggered a stop-loss and pulled back internally. The Basic mode can't see that process — it only uses open/high/low/close. If you're doing long-term automated trading, Premium is usually the threshold — webhook, which auto-POSTs alert triggers to your own server or third-party service, isn't available on Basic from the start. We broke down the five plans' actual differences with webhooks in[Five Plans Compared: Backtesting and Webhook Differences](/blog/en/tradingview-plans-webhook-comparison) — we won't repeat it here.

Strategy Tester Panel: What Each Tab Is Showing You

After adding a script to the chart, the Strategy Tester panel below lists several tabs, each serving different decisions — looking at the wrong one means you'll miss critical information. Below are the core tabs you'll likely use (actual listed tabs and names may vary slightly with TradingView version):

TabWhat It Shows YouWhen to Look at It
OverviewNet Profit, Percent Profitable, Profit Factor, Max Drawdown, and other summariesFirst glance to judge whether the strategy is worth continuing
Performance SummaryBreaks down each signal into All / Long / Short columns; includes Sharpe, Sortino, etc.Deciding whether to run only long, only short, or both
List of TradesTime, price, profit, run-up, drawdown for every single entry/exitFinding which single trade caused Max Drawdown to blow up
PropertiesAll strategy() parameters used in this backtest, including unchanged defaultsDocumenting the backtest; cross-referencing settings six months later

Strategy Tester core tabs and purposes (Pine Script v6, verification date: September 2026)

A common oversight is Properties.Most people only look at Overview before drawing conclusions, but the numbers on Overview are calculated using whatever settings are on Properties. If you don't click into Properties to cross-reference, you won't know what default produced that 68% win rate — initial_capital of 1 million, fixed 1 contract per trade, zero commission, zero slippage. These are Pine defaults, not your real situation. Section Five lists them all.

The Five Bold Numbers on Overview, Each One Can Be Faked

The Overview page displays five summary numbers in the largest font. Each has its own traps, and it's easy to be led astray by pretty curves when reading through them in order.

Bottom line up front: any single number can be optimized to look good
Net Profit can be inflated by adding positions; win rate can be boosted by widening stops; Profit Factor can be pumped by reducing trade count. These five numbers only make sense when viewed together — looking at a single one is worse than not looking at all, because it gives you false confidence in the strategy.

Net Profit:The sum of all closed trades' P&L, minus commissions and slippage. The absolute amount itself means nothing — when default_qty_type is percent_of_equity, larger principal produces larger Net Profit; results from two different principals can't be directly compared. Look at this number alongside the Net Profit % next to it, or adjust initial_capital to your real trading amount and recalculate.

Percent Profitable (Win Rate):Profitable trades ÷ total trades. High win rate doesn't mean profitable — if you win $10 each time and lose $100 each time, even an 80% win rate means you're losing money. This is why the next number matters more.

Profit Factor:Total profit from winning trades ÷ total loss from losing trades. 1 means break-even; anything above 1 is meaningful. Practical judgment benchmarks: below 1.2 usually won't survive real-world slippage and commissions; above 2.0 you should first suspect that commission or slippage isn't set (Section Five).

< 1
Profit Factor is losing — don't bother looking further
1.0–1.2
Break-even zone; after real costs, mostly a loss
1.5–2.0
Worth continuing to verify, but check sample size
> 2.5
First suspect commission/slippage not set

Max Drawdown:The largest drawdown from peak to trough during the **backtest period**. This is "the worst that historically happened," not "the worst that could happen going forward" — a deeper drawdown may appear out of sample. When you look at this number, ask yourself: would I have closed the strategy if I really saw my account drop this much at that moment? If yes, this strategy hasn't truly been backtested on you yet.

Total Closed Trades:How many trades the strategy completed in this history. When this number is too small (e.g., under 10), the four numbers above have zero statistical meaning — one lucky streak can make win rate and Profit Factor look great. Rough rule of thumb: **single digits ignore, double digits suspect, triple digits start to be meaningful**.

Five strategy() Default Values That Directly Change Your Backtest Results

The strategy() declaration function has thirty-something parameters, all with defaults. Leave them all blank and it compiles fine and produces a pretty performance table — but those numbers are **calculated using the official defaults**. This is where beginners get tricked most easily. Below are the five that have the biggest impact:

(One) Three parameters related to capital and position size

ParameterOfficial DefaultHow to Set in Reality
initial_capital1000000Set to the amount you'd actually trade, matching your exchange balance
default_qty_typestrategy.fixedMost people want strategy.percent_of_equity
pyramiding0 (rejects adding positions)Confirm you don't need pyramiding; set to 2, 3, etc. if you do

Pine Script v6 strategy() capital/position defaults (verification date: September 15, 2026)

(Two) Two parameters related to cost

ParameterOfficial DefaultHow to Set in Reality
slippage0 (ticks)For crypto perpetuals, use 1–3 ticks; more for highly volatile pairs
commission_value0Use the exchange's actual taker fee rate; check on that exchange's page

Pine Script v6 strategy() cost defaults (verification date: September 15, 2026)

pyramiding = 0 is something many people misread
The official strategy() reference for pyramiding reads "If the value is 0, only one entry order in the same direction can be opened, and additional entry orders are rejected" — default 0 means "only one entry per direction allowed; subsequent same-direction entries are rejected." So if you call strategy.entry("Long", strategy.long) twice in a script, the second won't add a position but will be discarded entirely. If your backtest results show dramatically fewer trades than expected, this is usually why. To enable pyramiding, you must actively set pyramiding = 2 or another specific number.

One easy-to-miss parameter: risk_free_rate. Pine v6 reference for it reads "It is used to calculate the Sharpe and Sortino ratios. Optional. The default is 2." — a default of 2 means 2%. This assumes the annual risk-free rate commonly used in stock markets; if you're evaluating crypto strategies, Sharpe and Sortino will run low. Whether to change this depends on what benchmark you're comparing against — verify what two numbers it affects before making a move.

The request.security Lookahead Trap Is a Separate Issue

If your strategy uses multiple timeframes (e.g., calling daily data inside an hourly script), there's another set of defaults that can make backtest numbers look unrealistically good. This topic already has a dedicated article:[The request.security Lookahead Trap: Beautiful Backtests That Don't Match Live Trading](/blog/en/request-security-lookahead-trap).

In one sentence: Pine v6's request.security has a parameter called lookahead, and the official reference for it reads "The default is barmerge.lookahead_off starting from Pine Script® v3." — **the default is already safe (won't sneak in future data)**. So that article actually covers the variant where "someone actively turned on lookahead_on" or "historical data aggregation itself has timing mismatches," not a defaults problem. This is a sixth parameter not included in Section Five's table because its default doesn't cause issues — only active changes do.

Heikin Ashi, Renko, and Other Non-Standard Charts: Officially "Not Recommended"

The Strategy Tester can run on Heikin Ashi, Renko, Point & Figure, and other non-standard charts, but the results will mislead. This isn't our opinion:

Official verbatim statement
"Strategies always use the chart's prices to enter and exit positions. Using them on non-standard chart types (Heikin Ashi, Renko, etc.) will produce misleading results, as their prices are synthetic. Backtesting on non-standard charts is thus not recommended." — Pine Script v6 Language Reference Manual, Remarks section on the strategy() page

The mechanism reason is that these chart types' candle prices are **synthesized**. Here's the comparison:

Chart TypeWhere Candle Prices Come FromSuitable for Backtesting
Standard CandlesActual open/high/low/close of the current candleYes
Heikin AshiAveraged from previous and current candle prices, not real tradesNot recommended by official docs
Renko / Kagi / Line BreakSynthesized candles auto-stacked from price movement thresholdsNot recommended by official docs
Point & FigureAdds a column only at specific price changes, no timeline candlesNot recommended by official docs

Why non-standard charts give you unrealistic backtest results (Pine Script v6, verification date: September 2026)

Pine's strategy.entry() uses synthetic prices as entry prices, which won't match what you'd actually trade on the market. Backtests look smooth; live trading reveals the same signals appear at the same time but with very different fill prices.

Workaround: strategy() has a fill_orders_on_standard_ohlc parameter; set to true it forces standard OHLC fills (even on Heikin Ashi charts). But this only fixes fill price, not the fact that signals themselves come from reading synthetic candles — for serious backtesting, just switch back to standard candle charts.

An Honest Section: Backtests Look Backward, Not Forward

By now you can read the panel numbers and know which defaults to change. But this must be stated clearly here — backtesting is fundamentally **using what has already happened** to approximate **what may happen in the future**, and the two will never perfectly align. This isn't a TradingView technical limitation; it's an inherent limitation of backtesting itself.

So even if you adjust all the defaults above to near-live conditions, your Profit Factor reaches 1.8, Max Drawdown is only 12% — the strategy could still blow up 15% in its first week on live trading. That doesn't mean you did anything wrong; it just means backtest numbers have never guaranteed that outcome.

What you should actually do is record your backtest results well — period, asset, parameters, initial capital, commission and slippage assumptions, all written down — then compare every single live trade's result against this record going forward. The bigger the gap between live and backtest, the more fragile the strategy's assumptions about the environment. There's no shortcut.

Backtest vs Live < 10%
Assumptions hold; absorbs environmental changes
10–30%
Noise present; usually underestimated commission/slippage or too small a sample
> 30%
Red flag; strategy overfit to a specific history, start over

Before going live with any new strategy, write these five things down and archive them. Six months later when you ask yourself "why is this behaving like this," this record is the only thing that can cross-reference the answer.

  • Backtest Period — which years, spanning which market conditions (bull, bear, sideways)
  • Asset — which exchange, which candle timeframe, which trading pair
  • Non-default strategy() Parameters — list all the parameters you actively changed and their values
  • Whether Bar Magnifier Is On — constrained by plan, state "off" explicitly if so
  • Commission and Slippage Assumptions — how much commission_value and slippage each is set to

Frequently Asked Questions

Can I use Basic plan backtest numbers?
For initial inspection, yes. To report externally, no. Basic has no Bar Magnifier — larger timeframes produce bigger deviation; daily strategies are barely referenceable, 5-minute charts with lots of intra-bar events have huge errors. For real detail, Premium is usually the threshold.
AI generated Pine that looks profitable in backtest — can I connect it to auto-trading?
First, adjust the five defaults from Section Five to your real conditions and rerun — in most cases those pretty numbers will drop by half. This is a necessary check, not optional. Also, backtest working doesn't mean auto-trading wiring works; the latter requires handling alert frequency, webhook delivery, exchange-side fill confirmation, which is a separate topic from this article.
Profit Factor above 3 — is that good?
First suspect that commission or slippage isn't set. Crypto perpetual taker fees commonly sit below 0.1%; conservative slippage at 2–3 ticks. Set those in and rerun; if Profit Factor is still above 2, there's something to compare. Pretty numbers from defaults (commission=0, slippage=0) equal trading in a frictionless vacuum, which is not the market you'll face.
Backtest and live results differ a lot — is TradingView broken?
Almost certainly not. Differences between backtest and live are normal. The causes usually fall into four areas: non-standard charts (Heikin Ashi, Renko), Bar Magnifier off, request.security settings on multi-timeframe, and the strategy's overfitting to a specific history. The first three can be fixed via settings; the last one requires[out-of-sample testing and overfit checks](/blog/en/quant-for-retail).
Can I publish backtest results on a blog or social media?
Yes, but the same paragraph must include three things: backtest period, asset and timeframe, and the phrase "past performance does not guarantee future results." Backtest screenshots missing any of these make it impossible for readers to judge whether those numbers apply to them. We follow this baseline on our own blog and dashboard — not a compliance requirement, just don't publish things you can't explain yourself.

Get started

Ready to ship what you just learned?

Backtest is running smoothly and you want to auto-connect signals to exchanges — TVSBot uses your own API key, starts with dry-run, risk controls are yours — turning Pine signals into real orders, no separate server needed.

Start Free