PINE LIBRARY

iterator

업데이트됨
The "Iterator" library is designed to provide a flexible way to work with sequences of values. This library offers a set of functions to create and manage iterators for various data types, including integers, floats, and more. Whether you need to generate an array of values with specific increments or iterate over elements in reverse order, this library has you covered.

Key Features:
  • Array Creation: Easily generate arrays of integers or floats with customizable steps, both inclusive and exclusive of the end values.
  • Flexible Iteration: Includes methods to iterate over arrays of different types, such as booleans, integers, floats, strings, colors, and drawing objects like lines and labels.
  • Reverse Iteration: Support for reverse iteration, giving you control over the order in which elements are processed.
  • Automatic Loop Control: One of the key advantages of this library is that when using the .iterate() method, it only loops over the array when there are values present. This means you don’t have to manually check if the array is populated before iterating, simplifying your code and reducing potential errors.
  • Versatile Use Cases: Ideal for scenarios where you need to loop over an array without worrying about empty arrays or checking conditions manually.

This library is particularly useful in cases where you need to perform operations on each element in an array, ensuring that your loops are efficient and free from unnecessary checks.


Library "iterator"
The "iterator" library provides a versatile and efficient set of functions for creating and managing iterators.
It allows you to generate arrays of integers or floats with customizable steps, both inclusive and exclusive of the end values.
The library also includes methods for iterating over various types, including booleans, integers, floats, strings, colors,
and drawing objects like lines and labels. With support for reverse iteration and flexible customization options.

iterator(stop, start, step)
  Creates an array of integers from start to stop with a specified step, excluding the stop value.
  Parameters:
    stop (int): The end value of the iterator, exclusive.
    start (int): The starting value of the iterator. Default is 0.
    step (int): The increment value for each step in the iterator. Default is 1. Must be greater than 0.
  Returns: An array of integers incremented by the step value from start to stop. Will return and empty array if start = stop.

iterator(stop, start, step)
  Creates an array of floats from start to stop with a specified step, excluding the stop value.
  Parameters:
    stop (float): The end value of the iterator, exclusive.
    start (float): The starting value of the iterator. Default is 0.
    step (float): The increment value for each step in the iterator. Default is 1. Must be greater than 0.
  Returns: An array of floats incremented by the step value from start to stop. Will return and empty array if start = stop.

iterator_inclusive(stop, start, step)
  Creates an array of integers from start to stop with a specified step, including the stop value.
  Parameters:
    stop (int): The end value of the iterator, inclusive.
    start (int): The starting value of the iterator. Default is 0.
    step (int): The increment value for each step in the iterator. Default is 1. Must be greater than 0.
  Returns: An array of integers incremented by the step value from start to stop, including the stop value.

iterator_inclusive(stop, start, step)
  Creates an array of floats from start to stop with a specified step, including the stop value.
  Parameters:
    stop (float): The end value of the iterator, inclusive.
    start (float): The starting value of the iterator. Default is 0.
    step (float): The increment value for each step in the iterator. Default is 1. Must be greater than 0.
  Returns: An array of floats incremented by the step value from start to stop, including the stop value.

itr(stop, start, step)
  Creates an array of integers from start to stop with a specified step, excluding the stop value.
  Parameters:
    stop (int): The end value of the iterator, exclusive.
    start (int): The starting value of the iterator. Default is 0.
    step (int): The increment value for each step in the iterator. Default is 1. Must be greater than 0.
  Returns: An array of integers incremented by the step value from start to stop.

itr(stop, start, step)
  Creates an array of floats from start to stop with a specified step, excluding the stop value.
  Parameters:
    stop (float): The end value of the iterator, exclusive.
    start (float): The starting value of the iterator. Default is 0.
    step (float): The increment value for each step in the iterator. Default is 1. Must be greater than 0.
  Returns: An array of floats incremented by the step value from start to stop.

itr_in(stop, start, step)
  Creates an array of integers from start to stop with a specified step, including the stop value.
  Parameters:
    stop (int): The end value of the iterator, inclusive.
    start (int): The starting value of the iterator. Default is 0.
    step (int): The increment value for each step in the iterator. Default is 1. Must be greater than 0.
  Returns: An array of integers incremented by the step value from start to stop, including the stop value.

itr_in(stop, start, step)
  Creates an array of floats from start to stop with a specified step, including the stop value.
  Parameters:
    stop (float): The end value of the iterator, inclusive.
    start (float): The starting value of the iterator. Default is 0.
    step (float): The increment value for each step in the iterator. Default is 1. Must be greater than 0.
  Returns: An array of floats incremented by the step value from start to stop, including the stop value.

method iterate(self, reverse)
  Creates an iterator array for the indices of ana array, with an option to reverse the order.
  Namespace types: array<bool>
  Parameters:
    self (array<bool>): The array to iterate over.
    reverse (bool): A boolean flag indicating whether to reverse the iterator order. Default is false.
  Returns: An array of integers representing the indices of the array. The order can be reversed if specified.

method iterate(self, reverse)
  Creates an iterator array for the indices of ana array, with an option to reverse the order.
  Namespace types: array<int>
  Parameters:
    self (array<int>): The array to iterate over.
    reverse (bool): A boolean flag indicating whether to reverse the iterator order. Default is false.
  Returns: An array of integers representing the indices of the array. The order can be reversed if specified.

method iterate(self, reverse)
  Creates an iterator array for the indices of ana array, with an option to reverse the order.
  Namespace types: array<float>
  Parameters:
    self (array<float>): The array to iterate over.
    reverse (bool): A boolean flag indicating whether to reverse the iterator order. Default is false.
  Returns: An array of integers representing the indices of the array. The order can be reversed if specified.

method iterate(self, reverse)
  Creates an iterator array for the indices of ana array, with an option to reverse the order.
  Namespace types: array<string>
  Parameters:
    self (array<string>): The array to iterate over.
    reverse (bool): A boolean flag indicating whether to reverse the iterator order. Default is false.
  Returns: An array of integers representing the indices of the array. The order can be reversed if specified.

method iterate(self, reverse)
  Creates an iterator array for the indices of ana array, with an option to reverse the order.
  Namespace types: array<color>
  Parameters:
    self (array<color>): The array to iterate over.
    reverse (bool): A boolean flag indicating whether to reverse the iterator order. Default is false.
  Returns: An array of integers representing the indices of the array. The order can be reversed if specified.

method iterate(self, reverse)
  Creates an iterator array for the indices of ana array, with an option to reverse the order.
  Namespace types: array<line>
  Parameters:
    self (array<line>): The array to iterate over.
    reverse (bool): A boolean flag indicating whether to reverse the iterator order. Default is false.
  Returns: An array of integers representing the indices of the array. The order can be reversed if specified.

method iterate(self, reverse)
  Creates an iterator array for the indices of ana array, with an option to reverse the order.
  Namespace types: array<linefill>
  Parameters:
    self (array<linefill>): The array to iterate over.
    reverse (bool): A boolean flag indicating whether to reverse the iterator order. Default is false.
  Returns: An array of integers representing the indices of the array. The order can be reversed if specified.

method iterate(self, reverse)
  Creates an iterator array for the indices of ana array, with an option to reverse the order.
  Namespace types: array<box>
  Parameters:
    self (array<box>): The array to iterate over.
    reverse (bool): A boolean flag indicating whether to reverse the iterator order. Default is false.
  Returns: An array of integers representing the indices of the array. The order can be reversed if specified.

method iterate(self, reverse)
  Creates an iterator array for the indices of ana array, with an option to reverse the order.
  Namespace types: array<label>
  Parameters:
    self (array<label>): The array to iterate over.
    reverse (bool): A boolean flag indicating whether to reverse the iterator order. Default is false.
  Returns: An array of integers representing the indices of the array. The order can be reversed if specified.

method iterate(self, reverse)
  Creates an iterator array for the indices of ana array, with an option to reverse the order.
  Namespace types: array<chart.point>
  Parameters:
    self (array<chart.point>): The array to iterate over.
    reverse (bool): A boolean flag indicating whether to reverse the iterator order. Default is false.
  Returns: An array of integers representing the indices of the array. The order can be reversed if specified.

method iterate(self, reverse)
  Creates an iterator array for the indices of ana array, with an option to reverse the order.
  Namespace types: array<polyline>
  Parameters:
    self (array<polyline>): The array to iterate over.
    reverse (bool): A boolean flag indicating whether to reverse the iterator order. Default is false.
  Returns: An array of integers representing the indices of the array. The order can be reversed if specified.

method iterate(self, reverse)
  Creates an iterator array for the indices of ana array, with an option to reverse the order.
  Namespace types: array<table>
  Parameters:
    self (array<table>): The array to iterate over.
    reverse (bool): A boolean flag indicating whether to reverse the iterator order. Default is false.
  Returns: An array of integers representing the indices of the array. The order can be reversed if specified.
릴리즈 노트
v2

Sped up reverse so that it dont have to sort lol.
릴리즈 노트
v3

fixed bug where it didnt make the arrays correctly
arraysMATHpinepinescriptpythonrangeutilitiesutility

파인 라이브러리

진정한 TradingView 정신에 따라, 저자는 이 파인 코드를 다른 파인 프로그래머들이 재사용할 수 있도록 오픈 소스 라이브러리로 공개했습니다. 저자에게 박수를 보냅니다! 이 라이브러리는 개인적으로 사용하거나 다른 오픈 소스 출판물에서 사용할 수 있지만, 이 코드를 출판물에서 재사용하는 것은 하우스 룰에 의해 관리됩니다.


또한 다음에서도:

면책사항