All free tools

Pine Script tool

Pine Script v6 Migration Checker

Paste a v5 script to see what v6 requires. The Pine Editor's built-in converter handles the mechanical rewrites and is the authority on those. What this adds is the list of changes that compile cleanly and behave differently, which is where migrations actually go wrong.

5 items found

  • Will not compileLine 1

    Version annotation says v5

    Change it to //@version=6. The Pine Editor also has a built-in converter under the Manage script menu, which does the mechanical work and is the authority on this; the script has to compile as valid v5 first.

  • Needs your decisionLine 1

    Strategy does not set margin_long or margin_short

    The v6 default is 100 rather than 0, so the strategy now enforces position-size limits against available funds. Expect a different trade count after migration even with identical entry rules.

  • Will not compileLine 8

    when parameter on a strategy order function

    The when parameter was deprecated in v5 and removed in v6, so this will not compile. Wrap the call in an if statement instead.

  • Will not compileLine 11

    transp parameter

    transp was removed everywhere in v6. Set transparency on the colour itself with color.new(colour, alpha) instead.

  • Behaviour changeLine 14

    timeframe.period compared without a multiplier

    In v6, timeframe.period always includes a multiplier, so a daily chart reads "1D" rather than "D". This comparison compiles and is simply never true, which makes it one of the quieter migration bugs.

Changes no checker can find for you

These are the v6 changes that cannot be detected from the text, because deciding whether they affect your script requires knowing what it means. They are also, not coincidentally, the ones that cause the migrations people struggle with, since each one leaves a script compiling cleanly while behaving differently.

  • Integer division now returns a float. In v5, 5 / 2 evaluated to 2 for constant integers. In v6 it evaluates to 2.5. Anywhere you relied on truncation, wrap the division in int() to keep the old behaviour. This changes results silently rather than failing to compile.
  • and / or now short-circuit. v6 evaluates the right-hand side only when needed. If a ta.* call sat on the right of an and, it may no longer run on every bar, which changes what its internal state contains. Pull such calls into the global scope so they are evaluated unconditionally.
  • Booleans can no longer be na. v5 allowed a boolean to be true, false, or na, and code sometimes used that third state deliberately. v6 does not. Where three states were encoded in a boolean, use an int instead, and guard values that can be na before using them in a condition.
  • Default strategy margin changed from 0 to 100. A migrated strategy now enforces position-size limits against available funds and can be subject to margin calls, so it may produce fewer or different trades with no change to its entry rules. Set margin_long and margin_short to 0 to reproduce v5 behaviour, but do so deliberately rather than to make old numbers reappear.
  • The offset parameter no longer accepts a series. Anywhere you passed a per-bar value as offset, it now needs to be simple or weaker. Fix it to a constant or an input, or restructure so the varying part is applied elsewhere.
  • The same parameter cannot be passed twice. v5 tolerated a duplicated named argument in a function call. v6 rejects it. This is a compile error rather than a silent change, so the editor will point at it.

Use the built-in converter first

TradingView ships an automatic converter in the Pine Editor, under the Manage script menu, and it should be your first step rather than this page. It does the mechanical work reliably: removing deprecated parameters, rewriting transparency calls, bumping the annotation, and flagging what it cannot resolve. Your script has to compile as valid v5 first for it to run.

What the converter cannot do is decide anything that depends on intent. It cannot know whether your integer division relied on truncation, whether a boolean was deliberately holding three states, or whether you want the v6 margin default or the v5 one. It will produce a script that compiles, and a script that compiles is not the same as a script that does what the old one did.

So the sensible order is: run the converter, then work through the checklist above, then compare results against the v5 version on the same symbol and period. A difference in trade count after migration is expected rather than alarming, particularly on a strategy, because the margin default changed. The thing to establish is that you can explain the difference.

Which changes actually break things

In practice the migration failures fall into three groups of very different difficulty. The removed parameters are trivial: when and transp stop compiling, the editor tells you exactly where, and the fixes are mechanical. Nobody loses an afternoon to these.

The strict boolean change is the one most likely to bite. In v5 a boolean could be na, and plenty of code relied on that without the author realising, particularly on early bars where an indicator has not warmed up. v6 requires a real true or false. Sometimes this is a compile error, which is the good case. Sometimes it is a behaviour change on the first few hundred bars, which is the bad case, because it is invisible unless you look there.

The quietest change is integer division. 5 / 2 was 2 in v5 and is 2.5 in v6. Anywhere a division fed a length, an index, or a count, the result may now be a fraction where a whole number was assumed. Nothing fails. The numbers simply differ, and tracing a small discrepancy back to a division you wrote two years ago is an unpleasant way to spend a day. Wrapping it in int() where truncation was intended is the fix. Our guide to v6 upgrade errors and the full migration walkthrough go through each of these with examples.

The sample, migrated

The corrected version above shows each fix from the sample. The when argument becomes an if around the call. transp becomes an alpha passed through color.new(). The timeframe comparison gains its multiplier. The division is wrapped in int(). And the declaration sets margin explicitly, with a comment saying why, rather than inheriting a default that changed underneath it.

That last one is the pattern worth copying. When a default changes between versions, setting it explicitly with a one-line comment is better than either accepting the new default silently or reverting it silently, because the next person to read the script can see that a decision was made.

Pine Script v6
//@version=6
strategy("The same strategy, migrated", overlay = true,
     // v6 defaults margin to 100. Setting it to 0 reproduces v5
     // behaviour; do this deliberately, not to make old numbers return.
     margin_long = 0, margin_short = 0)

fast = ta.sma(close, 10)
slow = ta.sma(close, 30)

// 'when' becomes an if wrapping the call.
if ta.crossover(fast, slow)
    strategy.entry("Long", strategy.long)

// transp becomes an alpha on the colour itself.
plot(fast, "Fast", color = color.new(color.blue, 40))

// timeframe.period now includes the multiplier.
isDaily = timeframe.period == "1D"

// int() restores truncation where the old behaviour was relied on.
halfLength = int(5 / 2)

plot(isDaily ? slow : na, "Slow")

PineScripter is an AI built specifically for Pine Script. You describe what you want in plain English and it writes TradingView-ready v6 code. Because it is specialized on the Pine Script language and its exact function signatures, it tends to produce code that compiles far more reliably than general-purpose models like ChatGPT, which often invent functions that do not exist in Pine Script.

Related free calculators

From the blog

PineScripter is an AI developer tool that helps you write Pine Script code. It is not a financial advisor and will never offer financial, investment, or trading advice. Everything on this page, including the calculator and the explanations, is provided purely for educational and informational purposes. Any decision about how to interpret an indicator or trade a market is entirely your own. See our full disclaimer for more.