Skip to main content
← Back to blog

Pine Script Strategy Has 0 Trades? 8 Causes & Fixes

📅 Published
✍️ Strategy Arena
TradingView Pine Script debugging strategy backtest research

When a TradingView Pine Script strategy shows 0 trades in Strategy Tester, the broker emulator is either never invoked (indicator() instead of strategy()), cannot afford the default order size (1 fixed unit exceeding initial_capital), or never sees your entry condition evaluate to true on any historical bar. Before tuning parameters, check the eight mechanical causes below — they account for almost every zero-trade script, especially code drafted by ChatGPT or Claude.

Test the corrected Pine v6 strategy from this guide directly in the free online strategy judge on BTCUSDT 1D (0.10% fee per side, final 20% sealed).

Published on 1 December 2026. Educational guide and research on past data, never investment advice.

Quick diagnostic table (8 causes)

# Symptom in TradingView Root cause Immediate fix
1 Strategy Tester stays blank Declared indicator() instead of strategy() Convert to strategy() + strategy.entry() (full conversion guide)
2 0 trades on BTC or expensive assets strategy.fixed (qty=1) costs more than initial_capital Set default_qty_type=strategy.percent_of_equity, default_qty_value=100
3 0–3 trades over several years Two ta.crossover() calls chained with and on the same bar Use one trigger event (crossover) + state filters (>, <)
4 Conditions silently stay false na propagation in var state or indicator warmup > chart bars Initialize var with 0.0 or guard with nz()
5 Entries fire, 0 closed trades strategy.close("L") ID mismatches strategy.entry("Long") Match IDs byte for byte or add strategy.exit()
6 Stops/targets never hit or hit instantly Passing price levels into profit/loss (which expect ticks) Use limit/stop for prices, or convert with syminfo.mintick
7 0 trades on your chosen timeframe Hard-coded timestamp() window outside visible chart dates Remove fixed end dates or check chart history start
8 Blocked after trade #1 pyramiding=0 with a permanently open position Ensure an exit or stop closes the open position

Cause 1: The script is still an indicator(), not a strategy()

TradingView only runs the broker emulator when the declaration is strategy(...). Scripts that call plotshape() or alertcondition() draw arrows on the chart while Strategy Tester reports 0 trades.

Replace indicator() with strategy() (including explicit capital, position size, and commission) and map each signal to strategy.entry() and strategy.close(). See our step-by-step walkthrough: Convert a TradingView Indicator into a Strategy.

Cause 2: strategy.fixed order size exceeds initial_capital

By default, a bare strategy("My Strategy") sets default_qty_type=strategy.fixed and default_qty_value=1. On Bitcoin at $90,000 (or an index future), buying 1 full unit requires more equity than a 10,000 default account when margin is not configured — so every order is silently skipped.

Always declare percentage-of-equity sizing and realistic fees in the header:

//@version=6
strategy("Sized With Fees", overlay=true,
     initial_capital=10000,
     default_qty_type=strategy.percent_of_equity,
     default_qty_value=100,
     commission_type=strategy.commission.percent,
     commission_value=0.1)

Cause 3: Chaining two simultaneous ta.crossover() events

ta.crossover(a, b) is true on one single bar — the exact bar where a crosses above b. Requiring two independent crossovers on the same candle (a classic mistake in AI-generated Pine scripts) shrinks trade frequency to near zero.

Broken — two crossovers on the same bar (0 sealed trades on BTCUSDT 1D):

//@version=6
strategy("Double Crossover (0 Trades Example)", overlay=true,
     initial_capital=10000,
     default_qty_type=strategy.percent_of_equity,
     default_qty_value=100,
     commission_type=strategy.commission.percent,
     commission_value=0.1)

emaFast = ta.ema(close, 9)
emaSlow = ta.ema(close, 21)
rsiVal  = ta.rsi(close, 14)

// Bug: requiring two rare crossovers on the exact same bar almost never triggers
if ta.crossover(emaFast, emaSlow) and ta.crossover(rsiVal, 50)
    strategy.entry("Long", strategy.long)
if ta.crossunder(emaFast, emaSlow)
    strategy.close("Long")

Fixed — one event trigger (crossover) + one state condition (rsiVal > 50):

//@version=6
strategy("EMA Trend + RSI State (Fixed)", overlay=true,
     initial_capital=10000,
     default_qty_type=strategy.percent_of_equity,
     default_qty_value=100,
     commission_type=strategy.commission.percent,
     commission_value=0.1)

emaFast = ta.ema(close, 9)
emaSlow = ta.ema(close, 21)
rsiVal  = ta.rsi(close, 14)

// Fix: one trigger event (crossover) combined with a state filter (rsiVal > 50)
if barstate.isconfirmed and ta.crossover(emaFast, emaSlow) and rsiVal > 50
    strategy.entry("Long", strategy.long)
if barstate.isconfirmed and ta.crossunder(emaFast, emaSlow)
    strategy.close("Long")

Measured on sa-pine-vm v3 (1 December 2026, BTCUSDT, 0.10% fees per side, final 20% sealed): - Broken double-crossover script: 1D produces only 10 training trades and 0 sealed trades (insufficient activity); 4h produces only 3 sealed trades. - Fixed trigger + state script: 1D produces 49 training trades and 16 sealed trades (+2.87% vs -23.25% Buy & Hold, max drawdown 24.67% vs 52.97%, verdict inconclusive); 4h produces 108 training trades and 32 sealed trades (-3.61% vs +15.83% Buy & Hold, no evidence of an edge).

Cause 4: na propagation and indicator warmup

In Pine Script, any arithmetic with na returns na, and any comparison against na evaluates to false (in Pine v6, booleans are strict and na is no longer coerced automatically — see our Pine Script v6 migration guide).

Common traps: - var float counter = na followed by counter := counter + 1 stays na forever. Initialize with 0.0 or use nz(counter[1], 0.0) + 1. - An indicator with a 500-bar warmup (ta.sma(close, 500)) on a chart that only loads 400 bars returns na on every single bar.

Cause 5: Mismatched strategy.entry() and strategy.close() / strategy.exit() IDs

If you open with strategy.entry("Long", strategy.long) and close with strategy.close("long") (wrong case) or strategy.exit("TP", from_entry="L", ...), the close/exit silently does nothing. With pyramiding=0 (the default), trade #1 stays open forever and Total Closed Trades stays at 0.

Keep entry IDs in a constant string or verify identical spelling across entry, close, and exit.

Cause 6: Confusing profit/loss (ticks) with limit/stop (prices)

In strategy.exit(): - stop and limit expect absolute price levels (e.g. strategy.position_avg_price * 0.97). - loss and profit expect integer ticks (1 tick = syminfo.mintick).

Passing a price like 60000 into loss or a percentage like 2 into stop either places an unreachable stop or closes trades instantly at invalid levels.

Cause 7: Hard-coded date windows or session filters

Many copied templates include inDateRange = time >= timestamp("2021-01-01") and time <= timestamp("2023-12-31"). On a 1h or 4h chart whose visible history starts in 2025 or 2026, inDateRange is false on every bar. Plot bgcolor(inDateRange ? color.new(color.green, 90) : na) temporarily to verify when your filter is actually active.

Cause 8: Debug systematically in 30 seconds

Add a temporary visual check to split your entry logic into individual booleans:

plotshape(ta.crossover(emaFast, emaSlow), title="Cond 1: Cross", style=shape.triangleup, location=location.belowbar, color=color.teal, size=size.tiny)
plotshape(rsiVal > 50, title="Cond 2: RSI > 50", style=shape.circle, location=location.top, color=color.orange, size=size.tiny)

Whichever series never plots on the chart immediately isolates the blocking condition.


Once your strategy trades: check it out of sample before trusting the curve

Fixing 0 trades only proves your syntax fires orders — it says nothing about whether the rule holds outside the bars used to write it. Before trusting a TradingView equity curve:

  1. Check for repainting and multi-timeframe leaks: How to Fix Repainting in Pine Script.
  2. Paste your script into the free online strategy judge (runs in your browser on BTCUSDT 1D/4h/1h with 0.10% fees and the final 20% sealed).
  3. Compare against classic open rules in the 29-strategy Pine library and the 8-market cross-market observatory, or export your TradingView List of Trades CSV for a free out-of-sample dossier preview.

⚠️ Disclaimer — This article is for informational and educational purposes only. It does not constitute investment advice or a buy/sell recommendation. Past performance does not guarantee future results. Strategy Arena is an educational simulator with virtual capital. Always do your own research before making investment decisions.

Enjoyed this article? Share it

𝕏 Share on X ✈️ Telegram

Turn a local result into durable proof

The Lab runs free on your PC. Certificates and audit dossiers use credits: 1 credit = 1 certificate or 1 dossier, 2 offered when you open an account; paying never changes the verdict.

Get the Lab (free)Audit a TradingView export Pricing and credits Publish a Lab Report Lab Reports Hall
TradingView Starter
Choose the account path. Prove the strategy separately.
Your first chart and price alert do not require the Lab. Strategy Arena proof remains required before trusting or exporting a strategy.
Partner attribution is for first-time users and web purchases only. Strategy Arena may earn a commission on eligible purchases; starting with a free account needs no payment.
I have never had an account · Start free I already have an account Check a strategy
More TradingView paths
Evidence-gated Pine review