Introduction to Pine Script™ v6
- Pine Script has been upgraded to v6, and all future updates will exclusively support this version.
- Upgrading from v5 to v6 is recommended to access new features and enhancements.
- Migration Guide: Details the changes in Pine behaviors and conversion steps for v5 scripts to v6.
New Features in Pine Script™ v6
1. Dynamic Requests
- Enhanced request.*() Functions:
- Accept "series string" arguments for parameters defining requested contexts.
- A single request.*() call can dynamically change its data feed on historical bars.
- These functions can now be called inside:
- Loops
- Conditional structures
- Exported library functions
- Learn More: Check the "Dynamic requests" section in the Other Timeframes and Data page.
2. Boolean Type Enhancements
- Strict Boolean Values:
- “bool” type values are strictly
true
orfalse
and neverna
.
- “bool” type values are strictly
- Lazy Evaluation:
- Operators
or
andand
now use short-circuit evaluation:- If the first expression in
or
istrue
, the second is skipped. - If the first expression in
and
isfalse
, the second is skipped.
- If the first expression in
- Benefits:
- Increased runtime efficiency for scripts using conditional expressions.
- Operators
3. Label and Text Enhancements
- Customizable Text Sizes:
- The
size
property (labels) andtext_size
property (boxes/tables) now supportint
values. - Sizes are in typographic points, offering more granular control.
- The
- Text Formatting Options:
- New
text_formatting
parameter for:label.new()
box.new()
table.cell()
- Supported formats:
text.format_bold
text.format_italic
text.format_none
- Modify formatting using corresponding
set_text_formatting()
functions.
- New
4. Strategy Enhancements
- Trade Limit Adjustments:
- Strategies no longer stop calculating when hitting the 9000 trade limit (outside Deep Backtesting mode).
- Oldest trades are trimmed to make room for new ones.
- Strategy Tester:
- Trimmed orders are invisible but do not affect simulations.
- Retrieve the earliest active trade’s index using
strategy.closedtrades.first_index
.
5. Array Enhancements
- Negative Indexing:
- Functions now support negative indices to reference elements from the end:
- Example:
array.get(myArray, -2)
retrieves the second-to-last element. - Equivalent to:
array.get(myArray, array.size(myArray) - 2)
.
- Example:
- Affected functions:
array.get()
array.set()
array.insert()
array.remove()
- Functions now support negative indices to reference elements from the end:
Tags
PineScript