Pine Script

Pine Script v6: What Changed From v5 and How to Convert Your Indicator

· 6 min read

TradingView released Pine Script v6 in December 2024. Most v5 indicators convert with one click, but a few changes alter how existing code behaves, especially around booleans, integer division and strategies. Here is what changed, what breaks, and how to convert.

How to convert a script to v6

Open the script in the Pine Editor, open the Manage script menu and choose Convert code to v6. The script must compile in v5 first. The converter fixes many changes automatically; others need a manual fix, which is what the rest of this guide covers. The first line becomes //@version=6.

The changes that break v5 code

Strategy changes

What's new

Running v6 indicators outside TradingView

TQ Charts, which draws charts from your NinjaTrader data, runs Pine Script indicators that you paste in, and reads the //@version line: v6 code uses v6 integer division and v5 code keeps the old behaviour. It accepts the text_formatting parameter and request.security() on higher timeframes of the same symbol. Strategies (strategy()) are not supported, only indicators. See Pine Script indicators outside TradingView, or converting Pine Script to NinjaTrader if you need it inside NinjaTrader itself.

FAQ

When was Pine Script v6 released?

TradingView announced Pine Script v6 on December 10, 2024.

How do I convert Pine Script v5 to v6?

In the Pine Editor, open Manage script and choose Convert code to v6. The v5 script has to compile first, and some changes need manual fixes.

Why does my indicator behave differently after converting to v6?

Usually because of lazy and/or evaluation, integer division returning fractions, or timeframe.period returning "1D" instead of "D".

Keep reading