TradingView’s Pine Script™ has evolved to version 6, introducing new features and improvements aimed at enhancing script flexibility, runtime efficiency, and developer experience. With updates ranging from dynamic data requests to new text formatting capabilities, Pine Script™ v6 sets the stage for creating more powerful and user-friendly trading tools. This guide highlights the key updates and what they mean for traders and developers.
Scripts can now call request.*()
functions with "series string" arguments, enabling them to dynamically adjust data feeds on any historical bar. Additionally:
request.*()
calls can now be placed inside loops, conditional structures, and library functions.Why It Matters
Developers can now build more adaptive strategies and indicators, dynamically pulling data based on changing conditions without rigid pre-setup requirements.
bool
) values are now strictly true
or false
, never na
.or
and and
use short-circuit evaluation, skipping unnecessary expressions.Why It Matters
These changes improve runtime efficiency, especially for scripts relying heavily on conditional logic.
text_formatting
parameter allows text objects (e.g., labels, boxes, tables) to display bold or italicized text.text.format_bold
, text.format_italic
, and text.format_none
.int
values, offering more granular control.Why It Matters
These updates enhance script aesthetics, helping developers create polished, professional-looking indicators.
strategy.closedtrades.first_index
variable retrieves the index of the earliest non-trimmed order.Why It Matters
This change ensures uninterrupted backtesting for high-frequency strategies, making it easier to analyze and refine them.
Functions like array.get()
, array.set()
, array.insert()
, and array.remove()
now accept negative indices, referencing elements from the end of an array.
Why It Matters
Developers gain a more intuitive way to work with arrays, simplifying operations like accessing or modifying the last few elements.
syminfo.mincontract
variable specifies the smallest tradable unit for the current symbol.syminfo.main_tickerid
and timeframe.main_period
, reference the main chart’s ticker ID and timeframe, regardless of context.Why It Matters
These features improve handling of continuous futures and multi-timeframe strategies, addressing long-standing challenges with symbol rollovers and main context references.
Follow the v6 migration guide to update scripts and take advantage of new features.
Try using dynamic request.*()
calls or negative array indices in your strategies to see the difference in flexibility and efficiency.
Update your script’s text objects to use bold or italic formatting for a professional finish.
Pine Script™ v6 represents a leap forward in script development, making it easier to build, maintain, and optimize trading tools. Whether you’re a trader seeking better strategies or a developer looking to refine your scripts, the updates in v6 offer tools to enhance both functionality and usability. Start upgrading your scripts today to unlock the full potential of this powerful new version.