Pine Script v6 is the current version of TradingView's scripting language, introduced in November 2024. TradingView's release notes say future Pine updates "will apply exclusively to this version". Some v6 changes are not compatible with v5 code: booleans can no longer be na, and/or evaluate lazily, the when parameter is gone and strategy defaults changed. The Pine Editor can convert many v5 scripts automatically; other changes need manual fixes.

Part of the Pine Script guide and function reference. Every change below comes from TradingView's v6 migration guide and release notes as of 25 September 2026.[1][2]
Pine Script v6 changes at a glance
TradingView's migration guide lists the changes that affect v5 scripts. Grouped by what they touch:[1]
Scroll horizontally to read every column.
| Area | v6 change, per the migration guide |
|---|---|
| Types | "int" and "float" are no longer implicitly cast to "bool"; "bool" values can no longer be na; na is not allowed in place of unique-type constants |
| Evaluation |
and and or evaluate lazily; for loops re-evaluate their end boundary before every iteration |
| Data requests | All request.*() functions can execute dynamically by default |
| Constants | Dividing two "const int" values can return a fractional value |
| Strategies |
when parameter removed; default margin 100; excess orders trimmed at the 9000 limit; strategy.exit() evaluates relative and absolute parameter pairs |
| Syntax and values |
[] cannot reference literals or user-defined type fields directly; no repeated arguments; plot() offset not "series"; timeframe.period always has a multiplier |
| Other | Negative indices for some array.*() functions; transp removed; some mutable variables correctly "series"; some default colours changed |
The release notes add new v6 features, such as dynamic requests, integer text sizes, a text_formatting parameter and syminfo.mincontract.[2]
How do you convert Pine Script v5 to v6?
The Pine Editor highlights a //@version=5 annotation in yellow. To convert, open the editor's "Manage script" menu and select "Convert code to v6". TradingView states three conditions:[1]
- A script can be converted only if its v5 code compiles successfully.
- In rare cases, automatic conversion produces a v6 script with compilation errors, which the Editor highlights for manual fixing.
- Scripts on v4 or earlier are converted one version at a time, using the earlier migration guides.
Compiling is not the same as behaving the same. Several changes below alter results without a compile error, so compare the converted script's plots, conditions and Strategy Tester results against the v5 version on the same chart.
Which v6 changes break or silently alter a v5 script?
Booleans have two states. In v5 a "bool" could be true, false or na. In v6, an unspecified if or switch branch returning "bool" gives false, and na(), nz() and fixnan() no longer accept "bool" arguments. Code that relied on a third state needs another type, such as an "int".[1] See nz() and missing values.
Numbers are not conditions. A numeric value where a "bool" is required must be wrapped in bool(). In v5, na, 0 and 0.0 were treated as false and other values as true.[1][3]
Lazy and/or. If the first part of an and is false, v6 skips the second part. A function that relies on previous values, such as ta.rsi(), can then miss bars and return incorrect values. TradingView's fix is to calculate such functions on every bar, for example in the global scope, and reference the variable in the condition.[1] The ta.crossover() guide applies this to crossover conditions.
Dynamic requests. A valid v5 script can behave differently after conversion in some obscure cases, even with unchanged request code. TradingView says dynamic_requests = false replicates "most of the previous v5 behavior".[1] The request.security() guide covers request timing.
Timeframe strings. timeframe.period now always includes a multiplier: "D" becomes "1D", "W" becomes "1W" and "M" becomes "1M". A v5 comparison such as timeframe.period == "D" is no longer true on a daily chart.[1]
Worked example: the same code, two results
Illustrative values taken from the migration guide's rules; not trading settings.[1]
| Expression | Pine v5 | Pine v6 |
|---|---|---|
5 / 2, both "const int" |
2 (integer division) | 2.5 |
timeframe.period on a daily chart |
"D" | "1D" |
Long exit: entry 100, tick 0.25, profit = 8, limit = 103
|
103 (absolute always wins) | 102 (triggers first) |
Default margin_long and margin_short
|
0 | 100 |
The exit row: the relative target is 100 + 8 × 0.25 = 102. v5 ignores it because limit is present; v6 uses whichever level the market price is expected to reach first, which for a long target is the lower 102.[1][3] For the integer result in v6, TradingView suggests int(5 / 2) or a rounding function.

What changes for strategies?
-
whenremoved: it affectedstrategy.entry(),strategy.order(),strategy.exit(),strategy.close(),strategy.close_all(),strategy.cancel()andstrategy.cancel_all(). Use anifstatement instead.[1] - Margin 100 by default: a v6 strategy does not open entries needing more money than is available, and short positions can be margin called. Setting both margin arguments to 0 replicates v5 behaviour.[1]
-
9000-order trimming: instead of stopping with an error outside Deep Backtesting, v6 trims the oldest orders. Trimmed orders no longer appear in the strategy report, and
strategy.closedtrades.first_indexgives the first remaining one.[1][2] -
Exit parameter pairs:
profit/limit,loss/stopandtrail_points/trail_priceare compared rather than the absolute value always winning.[1] See strategy.entry() and strategy.exit().
Margin, trimming and exit changes can alter Strategy Tester trades, and therefore order fill alerts, without any edit to the trading logic.
Illustrative sketch; not compiled or tested. Paste into the Pine Editor to see two v6 replacements; the lengths are arbitrary and the script is not a trading rule.
//@version=6
strategy("v6 migration patterns", overlay = true)
fast = ta.sma(close, 14)
slow = ta.sma(close, 28)
longCondition = ta.crossover(fast, slow)
// v5 allowed: strategy.entry("Long", strategy.long, when = longCondition)
if longCondition
strategy.entry("Long", strategy.long)
// v5 accepted a number as a condition; v6 needs an explicit bool() cast
bgcolor(bool(bar_index % 2) ? color.new(color.blue, 90) : na)
What happens to existing alerts after converting to v6?
Nothing changes automatically. Creating an alert saves a snapshot of the script, its inputs and the chart context on TradingView's servers. TradingView says changes to the script "do not affect that created alert", so a converted v6 script does not replace the code an existing alert runs.[4]
To use the v6 version, delete the old alert and create a new one from the converted script. The guide to alerts using old Pine Script settings covers this symptom. Removing the old alert also avoids running v5 and v6 alerts side by side.
PineConnector's Pine Script converter accepts supported Pine Script v5 and v6 strategies and indicators. It tells users to replace the old alert after changing inputs and to remove duplicates.[5]
Before re-enabling an automated alert, check it end to end on demo accounts only. Every account sharing the License ID must be a demo account, as the demo test guide states. Check the alert trigger, webhook delivery, PineConnector processing, the EA's order request and the broker's resulting position separately.[6]
What should you check after migrating?
- Compile first, then compare behaviour: the converter needs compiling v5 code, and a clean v6 compile does not prove identical output.[1]
-
Boolean logic: find places that depended on a boolean
naor on a number used as a condition. -
History-dependent calls inside conditions: move them to the global scope before lazy
and/or. - Strategy results: compare trades after the margin, trimming and exit-pair changes.
- Timeframe comparisons: search for literal "D", "W" or "M".
- Alerts: recreate each alert from the v6 script, then remove the v5 one.[4]
Frequently asked questions
What changed in Pine Script v6?
TradingView's migration guide lists the v5-incompatible changes. Booleans can no longer be na, numbers are not cast to booleans implicitly, and and/or evaluate lazily. Requests can be dynamic by default and const integer division can be fractional. Strategies lose when, default to 100% margin, trim excess orders and compare strategy.exit() parameter pairs.
How do I convert a Pine Script v5 script to v6?
Open the script in the Pine Editor, open the "Manage script" menu and select "Convert code to v6". The v5 code must compile first. TradingView says conversion can occasionally leave compilation errors to fix manually. After conversion, compare the script's behaviour, because lazy evaluation, boolean and strategy-default changes can alter results without errors.
Do my existing TradingView alerts switch to v6 after I convert a script?
No. A TradingView alert stores a snapshot of the script, inputs and chart context when it is created, and later script changes do not affect it. After converting to Pine Script v6, delete the existing alert and create a new one from the converted script, so only the intended version keeps running.
Why does my strategy give different results in Pine Script v6?
Three v6 strategy changes can alter results: the default margin for long and short positions is now 100 instead of 0, orders beyond the 9000 limit are trimmed, and strategy.exit() uses whichever of a relative or absolute level triggers first. Lazy and/or evaluation can also change indicator values used by conditions.
Reviewed 25 September 2026. Facts were checked against the linked sources on that date. Nothing in this article was tested on a trading account and no code was compiled.
Related reading
- Pine Script guide and function reference
- TradingView alert uses old Pine Script settings
- strategy.entry(), exit, close and order
- Pine Script nz() and na values
Sources
- TradingView – To Pine Script version 6, accessed 25 September 2026.
- TradingView – Pine Script release notes: November and December 2024, accessed 25 September 2026.
- TradingView – Pine Script v6 Reference Manual: bool() and strategy.exit(), accessed 25 September 2026.
- TradingView – Pine Script FAQ: Alerts, accessed 25 September 2026.
- PineConnector – Pine Script converter, accessed 25 September 2026.
- PineConnector – Test your setup, accessed 25 September 2026.
PineConnector executes the instructions you send it. It does not select trades, manage money, or hold funds. Trading carries risk, and past performance of any strategy does not indicate future results.