Pine Script strategy not taking trades
Paste the strategy and press Run. It runs as written on real data, and when it makes no trades the tester says why if it can tell. Free and unlimited with an account, no card.
| A breakout of a high that counts its own barQQQ daily | 0 → 51 |
| A value frozen at the first barQQQ daily | 0 → 37 |
| An order bigger than the accountQQQ daily | 0 → 51 |
| Contracts that round down to zeroNQ1! and MNQ1! 5-minute | 1 → 499 |
| A date window the bars don't reachMNQ1! 5-minute | 0 → 248 |
Runs through this tester on 16 November 2026: QQQ's daily bars since 2016, MNQ1! and NQ1! on two years of 5-minute bars.
Paste your script
Pine v6, as TradingView has it.
| A breakout of a high that counts its own barQQQ daily | 0 → 51 |
| A value frozen at the first barQQQ daily | 0 → 37 |
| An order bigger than the accountQQQ daily | 0 → 51 |
| Contracts that round down to zeroNQ1! and MNQ1! 5-minute | 1 → 499 |
| A date window the bars don't reachMNQ1! 5-minute | 0 → 248 |
Runs through this tester on 16 November 2026: QQQ's daily bars since 2016, MNQ1! and NQ1! on two years of 5-minute bars.
Paste the script above and press Run.
When it makes no trades, the tester says why if it can tell: an order bigger than the account, a value frozen at the first bar, an indicator with nothing to trade from.
A breakout written with ta.highest(high, 20) and no [1] can never fire: the close can't beat a high that includes itself. In our run on QQQ's daily bars since 2016: 0 trades. With [1]: 51.
Five causes, each run both ways
Each of these leaves a Pine Script strategy with no trades, or nearly none. Every count here is a run through this tester on real data, with the one line changed.
1. A breakout of a high that counts its own bar
ta.highest(high, 20) includes the bar being tested, and no close is above its own bar's high, so the entry can never fire. On QQQ's daily bars since 2016: 0 trades. With the channel read from the bars before it: 51.
if close > ta.highest(high, 20)if close > ta.highest(high, 20)[1]2. A value frozen at the first bar
var keeps the value it gets on the first bar unless a line sets it again. A 20-day average has no value yet on the first bar, so the filter compared every day's range with nothing and the entry never fired: 0 trades on QQQ since 2016. Without var it updates every bar: 37. The tester names the line when it sees this.
var float avgRange = ta.sma(high - low, 20)float avgRange = ta.sma(high - low, 20)3. An order bigger than the account
500 shares of QQQ cost many times a $25,000 account, and Pine's default margin of 100% asks for the whole price in cash. Every entry fired and none was filled: 0 trades. At 40 shares: 51. The tester says “Every order was bigger than the account” when it sees this.
initial_capital=25000, default_qty_type=strategy.fixed, default_qty_value=500initial_capital=25000, default_qty_type=strategy.fixed, default_qty_value=404. Contracts that round down to zero
A script that sizes from risk rounds down to whole contracts and skips a size under one. The opening range study's script risks 1% of $50,000, $500; on NQ1!, at $20 a point, a 15-minute range's stop usually costs more than that for one contract, so it traded once in two years. The same line on MNQ1!, at $2 a point, traded 499 times.
qty = math.min(maxContracts, math.floor(riskCash / ((stopPts + 2 * syminfo.mintick) * syminfo.pointvalue))) // NQ1!: 1 tradeqty = math.min(maxContracts, math.floor(riskCash / ((stopPts + 2 * syminfo.mintick) * syminfo.pointvalue))) // MNQ1!: 499 trades5. A date window the bars don't reach
A test window written into the script limits its entries to those dates. With the window on 2023 and the bars starting in October 2024, the study's script took 0 trades on MNQ1!; with the window on 2025, 248. On a chart, the bars it has loaded decide the same thing.
fromDate = input.time(timestamp("2023-01-01"), "Test from")fromDate = input.time(timestamp("2025-01-01"), "Test from")Check your script
Paste it in the box at the top. It runs as written, with costs charged, and the tester says what stopped it when it can tell.
Free account
No card, no time limit.
- Unlimited backtests, costs charged, with the out-of-sample check
- The Pine script audit and the full trade list
- The Pine Copilot writes and edits your script
- 50 AI credits a day

Prop Ready opens all two years of futures minute bars on a computer for $39 paid once and has 7 days money back. Pro adds the optimiser and every AI tool and has 30 days money back. See the plans
Questions
Why does my Pine Script strategy show no trades?
Most often one of five things: a breakout of a high that counts its own bar, a value frozen at the first bar by var, an order bigger than the account, a size that rounds down to zero contracts, or a date window the bars don't reach. Paste the script above and run it: when the tester can tell, it names the cause, and each one below is shown with the line that breaks it and the line that fixes it.
Why does it trade on TradingView but not here?
Usually the bars differ. This tester runs US stocks and ETFs on regular-session bars, reading the pre-market or after-hours only when the script asks for them, and futures on the Nasdaq-100, the S&P 500, crude oil, gold, silver, copper, platinum and palladium. It runs years of history where a chart may hold weeks, so a date window or a warm-up written for one can miss the other. And it takes Pine v6: TradingView's Pine Editor converts most v4 and v5 scripts with its convert command.
How do I see which condition never comes true?
Plot each condition on its own, for example plotshape(longSetup) or bgcolor(longSetup ? color.new(color.green, 80) : na). The one that never lights up is the one stopping the entry. In the Alpha Charts terminal the script's plots and marks show on the chart beside its trades, so a setup that never marks a bar is easy to spot.
Can the AI fix it?
Yes. In the Alpha Charts terminal, Fix it sends the script and the tester's reason to the Pine Copilot, which edits the line and runs the backtest again. The Free plan includes 50 AI credits a day, with no card.
More on scripts that misbehave
The mistakes AI writes into Pine Script, each with its fix: the AI Pine Script generator. A script that will not compile, by TradingView's error message: AI-written Pine Script that won't compile. A line-by-line check of a script before it runs: the Pine Script audit. The tester on its own: the free Pine Script backtester.
The runs went through this tester's engine on 16 November 2026: QQQ's daily bars from 4 January 2016 to 13 November 2026, and MNQ1! and NQ1! 5-minute bars from 23 October 2024 to 22 October 2026, with costs charged. Pine's default margin of 100% is from TradingView's Pine Script manual, “Strategies”, read the same day. TradingView and Pine Script belong to TradingView, Inc.; Alpha Charts is not affiliated with it. Updated 28 November 2026.