Pine Script v5 vs v6: What's New and Improved?

 



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 or false and never na.
  • Lazy Evaluation:
    • Operators or and and now use short-circuit evaluation:
      • If the first expression in or is true, the second is skipped.
      • If the first expression in and is false, the second is skipped.
    • Benefits:
      • Increased runtime efficiency for scripts using conditional expressions.

3. Label and Text Enhancements

  • Customizable Text Sizes:
    • The size property (labels) and text_size property (boxes/tables) now support int values.
    • Sizes are in typographic points, offering more granular control.
  • 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.

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).
    • Affected functions:
      • array.get()
      • array.set()
      • array.insert()
      • array.remove()

Post a Comment

Previous Post Next Post