Troubleshooting symptom

Why a Pine Script strategy shows no trades

An empty Strategy Tester is a troubleshooting symptom. Check order calls, whether entry conditions trigger, date/session filters, runtime errors, and exits. Verify capital and sizing against the symbol’s price, point value, quantity increments, and margin. This example lowers the default cash amount, which can still fall below the instrument’s minimum tradable quantity. It has no exit and therefore does not ensure closed trades or repeated entries. Test those conditions on the actual chart.

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 MCP pine-script-syntax-checker; static diagnostics only
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