You asked TradingView's AI Copilot for a breakout indicator, it answered in a few seconds, and the script is already on your chart. The Pine Editor shows no red text. And yet nothing happens. Or the opposite: the markers appear, you reload the chart tomorrow, and half of them are gone. This is one of the most frustrating states in Pine Script work, because there is no error message to search for. The code looks finished, and it simply does not do what you asked.
This guide is for that moment. It covers the three ways AI-written Pine Script goes wrong (it fails to compile, it compiles but never triggers, it triggers but repaints), how to tell which one you have in under a minute, and how to fix each with the smallest possible change. The examples are generic Pine Script v6 problems that show up with any AI tool, including TradingView's own, so the method works whether the draft came from TradingView, a general chatbot, or a freelancer.
What TradingView's AI Copilot is, and what it is not
TradingView's help page for AI Copilot describes it as an assistant in the side panel of the chart. It uses TradingView's own data to answer questions and act on your chart, and one of its jobs is writing Pine Script: you describe an indicator or strategy in plain language and it is generated and applied to your chart. It is a separate monthly add-on on top of a paid TradingView plan, with a monthly usage limit.
That design has real strengths, and they are worth stating plainly. It lives where your chart lives, it can see TradingView's data, and it can act on the chart directly. PineScripter does not try to match that, and nothing below is an argument that you should stop using it. It is a fast way to get a first draft next to the chart.
The same help page also says Copilot can be wrong or use outdated information. That sentence applies to code as much as to numbers. A first draft is a draft, and the skill that matters is knowing how to audit one. Pine Script makes this harder than most languages because a script can be syntactically perfect and still be wrong in ways the compiler cannot see.
Step one: sort the failure into one of three bins
Before you change anything, decide which of these you are looking at, because the fix for each is completely different.
The first bin is a compile failure. The Pine Editor shows a red error on save or on adding the script to the chart. This is the easy one, because the error text tells you the line and usually the cause.
The second bin is a script that compiles and plots, but a condition never becomes true, or becomes true at the wrong place. The editor is silent. You find out only by looking at the chart.
The third bin is a script that looks right on the bars you have already watched close, but marks things differently when a bar is still forming, or differently after a reload. That is repainting, and it is a property of how the data was requested or how the condition was evaluated.
If you cannot tell, run the script and scroll to the right edge of the chart. Compile failures stop you before that. Never-triggers scripts show a chart with plots but no markers at all. Repainting scripts show markers that flicker on the live bar and settle differently once it closes.
Bin one: compile failures from the wrong Pine Script version
The most common compile failure in AI-written code is version drift. Models were trained on far more Pine Script v4 and v5 than v6, so a draft that begins with //@version=6 can still contain v5 habits underneath. The classic example is an entry call that uses the when argument, which v6 removed from the strategy order functions.
//@version=6
strategy("Breakout", overlay = true)
longCond = ta.crossover(close, ta.sma(close, 20))
strategy.entry("Long", strategy.long, when = longCond)TradingView rejects the call because when is no longer a parameter. The fix is to move the condition into an ordinary if block, which also makes the logic easier to read.
//@version=6
strategy("Breakout", overlay = true)
longCond = ta.crossover(close, ta.sma(close, 20))
if longCond
strategy.entry("Long", strategy.long)Other v6 changes produce similar breaks. Numbers are no longer silently treated as booleans, so if close or if bar_index is rejected where it once passed. Old namespace-less functions such as security have long been replaced by request.security. If the error text mentions an unknown function or a missing argument, look up the current name before assuming the logic is wrong. Our guides to common Pine Script compile errors and to errors after upgrading to v6 list the patterns in more detail, and the free Pine Script validator will show you the error without opening TradingView.
When you ask any AI to repair a compile error, paste the exact error text and the line it points to, not a description of it. The compiler is the authority here, and a paraphrase throws away the one precise piece of information you have.
Bin two: it compiles, and the condition never fires
This is the case that costs the most time, because nothing tells you where to look. The pattern is so common in generated breakout code that it deserves its own walkthrough. Here is a Donchian-style breakout, written the way a quick first draft often is.
//@version=6
indicator("Donchian breakout (draft)", overlay = true)
length = input.int(20, "Length", minval = 2)
upper = ta.highest(high, length)
lower = ta.lowest(low, length)
longBreak = close > upper
shortBreak = close < lower
plot(upper, "Upper", color = color.teal)
plot(lower, "Lower", color = color.maroon)
plotshape(longBreak, "Long break", style = shape.triangleup, location = location.belowbar, color = color.green, size = size.small)
plotshape(shortBreak, "Short break", style = shape.triangledown, location = location.abovebar, color = color.red, size = size.small)It compiles. The bands draw correctly. No triangle ever appears. The reason is that ta.highest(high, length) includes the current bar. The current bar's close can never be above the highest high of a window that contains that same bar's high, so close > upper is always false. The comparison is logically impossible, not merely rare.
The fix is to compare against the channel as it stood before the current bar, using the history operator.
//@version=6
indicator("Donchian breakout (fixed)", overlay = true)
length = input.int(20, "Length", minval = 2)
upper = ta.highest(high, length)
lower = ta.lowest(low, length)
longBreak = close > upper[1]
shortBreak = close < lower[1]
plot(upper, "Upper", color = color.teal)
plot(lower, "Lower", color = color.maroon)
plotshape(longBreak, "Long break", style = shape.triangleup, location = location.belowbar, color = color.green, size = size.small)
plotshape(shortBreak, "Short break", style = shape.triangledown, location = location.abovebar, color = color.red, size = size.small)The change is two characters per line. That is the point worth keeping: a working fix to a script that compiles is usually tiny, and the hard part is finding the line. A useful habit is to split a composite condition into named pieces and plot each one, so you can see which piece is false when it should be true. If you want a systematic version of this, our guide to debugging Pine Script when there is no error message walks through it, and the post on strategies that take no trades covers the strategy-specific causes, such as order sizing and pyramiding settings.
Two other silent causes are worth checking in the same pass. If a condition uses na values, the whole expression can quietly become na, which behaves as false; see how Pine Script handles na. And if a condition combines two events with and, check that both can actually be true on the same bar. A crossover and a volume spike on exactly the same bar is a much rarer thing than either alone.
Bin three: it fires, but it repaints
The third failure is the most damaging because the script appears to work. A common source is a higher-timeframe request written with lookahead_on, which AI tools add because it makes the daily value appear on intraday bars immediately.
//@version=6
indicator("Daily close (draft)", overlay = true)
dailyClose = request.security(syminfo.tickerid, "D", close, lookahead = barmerge.lookahead_on)
plot(dailyClose, "Daily close", style = plot.style_stepline)On history, this line leaks information. Each intraday bar sees the day's final close before that day has finished, so the plot looks impossibly well timed. On the live bar it behaves differently, and the two disagree. The fix is to shift the requested series back one bar, so that you only ever read a value that was already final.
//@version=6
indicator("Daily close (fixed)", overlay = true)
prevDailyClose = request.security(syminfo.tickerid, "D", close[1], lookahead = barmerge.lookahead_on)
plot(prevDailyClose, "Previous daily close", style = plot.style_stepline)The deeper explanation is in Pine Script lookahead explained and in the broader guide to the five kinds of repainting. The other frequent cause is a condition that is allowed to fire while the bar is still open. For alerts, the standard remedy is to require a confirmed bar.
//@version=6
indicator("Confirmed cross alert", overlay = true)
fast = ta.ema(close, 9)
slow = ta.ema(close, 21)
crossUp = ta.crossover(fast, slow) and barstate.isconfirmed
plot(fast, "Fast", color = color.blue)
plot(slow, "Slow", color = color.orange)
plotshape(crossUp, "Cross up", style = shape.triangleup, location = location.belowbar, color = color.green, size = size.small)
alertcondition(crossUp, "Cross up", "Fast EMA crossed above slow EMA")Requiring barstate.isconfirmed means the marker appears only once the bar has closed, which costs you one bar of delay and removes the flicker. Our walkthrough of barstate.isconfirmed covers the tradeoffs, including why it is not a cure for every kind of repainting.
A repeatable triage routine for any AI-written script
Once you have seen the three bins, the routine is short enough to memorize. First, make the script compile, using the exact error text. Second, load it on a chart with enough history, and check that every condition you care about is true at least once; if one never is, isolate and plot it. Third, scroll to the live bar and watch it for a few minutes on a short timeframe; anything that appears and disappears is a repaint candidate. Fourth, ask for the smallest change that fixes the one problem, and read the diff before you accept it.
That last step matters more than it sounds. When you tell a general chatbot that your breakout never triggers, it will often rewrite the whole script, and the rewrite brings new variable names, a different structure, and sometimes new bugs in code that was fine. You then have to audit everything again. A targeted fix keeps the review small. The same discipline applies to any tool: ask for one change, expect one change, and verify that only that one changed. If you want a longer checklist, see how to check AI-generated Pine Script before you use it.
Where a dedicated workspace helps
Copilot's model is to describe, generate, and apply to the chart. That is quick, but once the script is applied the conversation that produced it is not the place you come back to. When a long script needs a third and fourth round of changes, you want the code, the history, and the diffs in one place.
This is what PineScripter is built for. You paste the script that misbehaves, and it explains what the code does in plain English. Every script is linted the same way TradingView checks it, the AI sees the compile errors and corrects them itself, and a follow-up request changes the affected lines rather than the whole file. The Code Changes view shows line by line what moved, so you can see that the fix to the Donchian comparison was two characters and nothing else. There is also a Chart that runs your script on real market data inside PineScripter, with up to 5,000 bars, and a Replay that steps through one bar at a time so you can see exactly when a condition reacts. The market data covers 308 crypto spot markets, so it does not replace checking a stock or forex script on TradingView.
Two honest limits apply. PineScripter does not read your TradingView chart, and it does not run backtests; for a strategy backtest you still use TradingView's Strategy Tester. And its plans use monthly credits, from $9.99 per month for Mini to $39.99 per month for Ultra, so it is not unlimited. You can see the details on the pricing page. The workflow that many people end up with is simple: get a first draft wherever is most convenient, then bring it to a place where you can take it apart properly.
Final thoughts
A script that compiles has cleared the lowest bar, not the highest. The failures that cost real time are the quiet ones: the condition that can never be true, and the series that sees tomorrow. Both are small in code and large in consequences, and both are easy to find once you know to look for them. Sort the failure into its bin, make the smallest fix, and confirm that only one thing changed.
Disclaimer: PineScripter is a coding tool for Pine Script development. It does not provide financial advice and does not guarantee trading profits. Always backtest strategies thoroughly and understand the risks before live trading.
Frequently asked questions
Why does my TradingView AI Copilot script compile but show nothing?
A condition is probably never true. A common cause is comparing close to a highest or lowest value that includes the current bar, which can never be exceeded. Compare against the previous bar's value with [1] and plot each condition separately to see which one stays false.
Why do the markers change after I reload the chart?
That is repainting. Typical causes are a request.security call with lookahead_on and no one-bar offset, or a condition that is allowed to fire while the bar is still open. Shift the requested series back one bar or require barstate.isconfirmed.
Can I paste a script written by another AI into PineScripter?
Yes. You can paste any Pine Script into PineScripter, which explains what it does, checks it for compile errors, and edits only the lines that need to change. Older v5 scripts are upgraded to v6.
Does PineScripter replace TradingView's AI Copilot?
No. TradingView's Copilot works on the chart and sees TradingView's data, which PineScripter does not. PineScripter is a separate code workspace for keeping, editing and checking a script.
Does PineScripter backtest my strategy?
No. It does not simulate trades or report returns. For a strategy backtest, use TradingView's Strategy Tester.
Describe your indicator in plain English and get Pine Script that compiles →
Disclaimer: PineScripter is a coding tool for Pine Script development. It does not provide financial advice and does not guarantee trading profits. Always backtest strategies thoroughly and understand the risks before live trading.