Troubleshooting symptom

Why a Pine Script strategy shows no trades

Treat an empty Strategy Tester as a troubleshooting symptom, not a single Pine compiler error. Confirm the script uses `strategy.entry()` or `strategy.order()`, log whether entry conditions ever become true, and check date or session filters. Then verify position size, initial capital, runtime errors, and exits. The example lowers an unaffordable default cash order, but another script may fail for a different branch of this checklist.

This link opens the Pine Script AI Coding Agent overview. It does not run or change code on this page.

Before and after

Make the smallest reviewable change

Both artifacts include the version declaration and the code needed to inspect the stated problem. The diff lists the lines that change between them.

Broken code.pine
//@version=6
strategy("No trades demo", initial_capital = 1000, default_qty_type = strategy.cash, default_qty_value = 100000)
bool longCondition = ta.crossover(ta.sma(close, 10), ta.sma(close, 20))
if longCondition
    strategy.entry("Long", strategy.long)
Fixed code.pine
//@version=6
strategy("No trades demo", initial_capital = 1000, default_qty_type = strategy.cash, default_qty_value = 100)
bool longCondition = ta.crossover(ta.sma(close, 10), ta.sma(close, 20))
if longCondition
    strategy.entry("Long", strategy.long)
Diff.pine
--- broken.pine
+++ fixed.pine
@@
-strategy("No trades demo", initial_capital = 1000, default_qty_type = strategy.cash, default_qty_value = 100000)
+strategy("No trades demo", initial_capital = 1000, default_qty_type = strategy.cash, default_qty_value = 100)

Root causes

  • The script never calls an order placement command, or its entry condition never becomes true.
  • Date, time, session, or direction filters exclude every eligible bar.
  • Initial capital or position sizing cannot fund the requested order.
  • A runtime error halts execution before orders are placed.
  • An open position lacks an exit, so later same-direction entries do not create new trades.

How the fix was verified

Method
Pineify UAT grammar checker via check-pine-script-grammar.mjs
Broken result
Returned no grammar diagnostics, which is expected for this non-error symptom.
Fixed result
Returned no grammar diagnostics.
Limit
Not runtime-tested. The example addresses insufficient capital only; inspect conditions, filters, order placement, runtime errors, and exits in the actual strategy.

Bring the actual script, not just the message

Open the Coding Agent overview to paste editable Pine Script, explain the intended behavior, and request a review. Compile and test the result in TradingView before using it.

Paste your code to fix this error