Pine Script™ v6: An Exciting Update for Traders and Developers

Pine Script™ v6 is here, bringing powerful updates like dynamic data requests, optimized boolean logic, precise text formatting, and enhanced strategy management. With new tools and improved efficiency, this update unlocks smarter trading possibilities.

Pine Script logo with trademarked name and v6
Pine Script Version 6 Released

On December 10th, TradingView announced the release of Pine Script™ v6, the latest iteration of the powerful scripting language designed for traders and developers. Packed with long-awaited enhancements and optimizations, this update delivers greater efficiency and flexibility, opening up new possibilities for TradingView users.

Here’s an overview of the standout features and improvements introduced in Pine Script™ v6.


Easier Upgrades with the v6 Conversion Tool

As with prior updates, scripts written in earlier versions of Pine Script™ remain fully functional. However, to leverage the new features exclusive to v6, it’s recommended to convert your scripts using the new v6 Conversion Tool. This tool, accessible through the “Manage script” menu in the Pine Editor, simplifies the process with an automated “Convert code to v6” option.

Note: While the tool streamlines many conversions, some scripts may require manual adjustments for compatibility. The detailed Migration Guide provides additional support for manual updates.

Dynamic Requests: A Game-Changer for Data Retrieval

Pine Script™ v6 introduces a major upgrade to the request.*() family of functions. Previously constrained to static inputs, these functions can now accept series string values, enabling dynamic data requests within loops, conditional statements, and library exports.

This enhancement unlocks exciting new capabilities, such as:

  • Fetching data dynamically for symbols across various historical bars.
  • Looping through collections of symbols to retrieve data programmatically.
  • Utilizing complex, context-dependent data retrieval strategies.

Example Use Cases:

Forex Heatmap: Dynamically requests data for currency pairs and visualizes it in a color-coded table.

forex heatmap indicator by TradingView
Forex Heatmap

Ticker Tape: Displays updated price and daily changes for user-defined symbols in a rotating ticker.

ticker tape indicator by TradingView
Ticker Tap

LibraryCOT: Now supports dynamic requests for CFTC Commitment of Traders data, offering improved flexibility and expanded symbol coverage.

library COT indicator by TradingView
Library COT

Boolean Optimization and Lazy Evaluation

Behind-the-scenes enhancements to how boolean (bool) values are processed significantly improve script performance, particularly for large, condition-heavy scripts. Key updates include:

  • Short-Circuit Evaluation: Logical operators (and, or) now stop evaluating as soon as the result is determined.
  • Cleaner Code: Lazy evaluation reduces errors and simplifies conditional logic. For instance, checking array bounds and accessing elements can now be done in a single statement.

This optimization not only boosts efficiency but also enhances code readability and maintainability.


Precision Text Formatting

Text elements in Pine Script™ have become more customizable with the introduction of typographic point sizes and the new text_formatting parameter. Whether you’re working with tables, labels, or boxes, you can now:

  • Specify text sizes in precise point values.
  • Apply bold and italic styles for improved visual clarity.

This improvement enables better control over the aesthetics of scripts, especially those intended for presentation or sharing with others.


Improved Strategy Order Management

For strategy developers, Pine Script™ v6 eliminates the 9000-trade limit that previously halted calculations. Instead, older trades are now automatically trimmed to accommodate new ones. This ensures uninterrupted simulations and more robust strategy development.

To track trimmed orders, the new strategy.closedtrades.first_index variable provides access to the trade index of the earliest remaining order.


Negative Array Indices for Greater Flexibility

With Pine Script™ v6, you can now use negative indices in array operations to reference elements from the end of an array. For instance, array.get(myArray, -1) retrieves the last element, while array.get(myArray, -2) retrieves the second-to-last, offering a more intuitive way to work with arrays.


Stay Informed with Regular Updates

For a comprehensive list of all updates in Pine Script™ v6, including additional improvements not covered here, check the Release Notes.


CrossTrade is dedicated to helping traders get the most out of innovative tools created with Pine Script™ and provide the fastest and most popular solution for sending TradingView webhooks to NinjaTrader.

Start your free trial

Try CrossTrade for 7 days.

Sign Up