iteratorThe "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
Parameters:
self (array) : 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
Parameters:
self (array) : 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
Parameters:
self (array) : 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
Parameters:
self (array) : 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
Parameters:
self (array) : 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
Parameters:
self (array) : 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
Parameters:
self (array) : 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
Parameters:
self (array) : 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
Parameters:
self (array) : 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
Parameters:
self (array) : 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
Parameters:
self (array) : 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
Parameters:
self (array) : 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.
Range
time_and_sessionA library that provides utilities for working with trading sessions and time-based conditions. Functions include session checks, date range checks, day-of-week matching, and session high/low calculations for daily, weekly, monthly, and yearly timeframes. This library streamlines time-related calculations and enhances time-based strategies and indicators.
Library "time_and_session"
Provides functions for checking time and session-based conditions and retrieving session-specific high and low values.
is_session(session, timeframe, timezone)
Checks if the current time is within the specified trading session
Parameters:
session (string) : The trading session, defined using input.session()
timeframe (string) : The timeframe to use, defaults to the current chart's timeframe
timezone (string) : The timezone to use, defaults to the symbol's timezone
Returns: A boolean indicating whether the current time is within the specified trading session
is_date_range(start_time, end_time)
Checks if the current time is within a specified date range
Parameters:
start_time (int) : The start time, defined using input.time()
end_time (int) : The end time, defined using input.time()
Returns: A boolean indicating whether the current time is within the specified date range
is_day_of_week(sunday, monday, tuesday, wednesday, thursday, friday, saturday)
Checks if the current day of the week matches any of the specified days
Parameters:
sunday (bool) : A boolean indicating whether to check for Sunday
monday (bool) : A boolean indicating whether to check for Monday
tuesday (bool) : A boolean indicating whether to check for Tuesday
wednesday (bool) : A boolean indicating whether to check for Wednesday
thursday (bool) : A boolean indicating whether to check for Thursday
friday (bool) : A boolean indicating whether to check for Friday
saturday (bool) : A boolean indicating whether to check for Saturday
Returns: A boolean indicating whether the current day of the week matches any of the specified days
daily_high(source)
Returns the highest value of the specified source during the current daily session
Parameters:
source (float) : The data series to evaluate, defaults to high
Returns: The highest value during the current daily session, or na if the timeframe is not suitable
daily_low(source)
Returns the lowest value of the specified source during the current daily session
Parameters:
source (float) : The data series to evaluate, defaults to low
Returns: The lowest value during the current daily session, or na if the timeframe is not suitable
regular_session_high(source, persist)
Returns the highest value of the specified source during the current regular trading session
Parameters:
source (float) : The data series to evaluate, defaults to high
persist (bool) : A boolean indicating whether to retain the last value outside of regular market hours, defaults to true
Returns: The highest value during the current regular trading session, or na if the timeframe is not suitable
regular_session_low(source, persist)
Returns the lowest value of the specified source during the current regular trading session
Parameters:
source (float) : The data series to evaluate, defaults to low
persist (bool) : A boolean indicating whether to retain the last value outside of regular market hours, defaults to true
Returns: The lowest value during the current regular trading session, or na if the timeframe is not suitable
premarket_session_high(source, persist)
Returns the highest value of the specified source during the current premarket trading session
Parameters:
source (float) : The data series to evaluate, defaults to high
persist (bool) : A boolean indicating whether to retain the last value outside of premarket hours, defaults to true
Returns: The highest value during the current premarket trading session, or na if the timeframe is not suitable
premarket_session_low(source, persist)
Returns the lowest value of the specified source during the current premarket trading session
Parameters:
source (float) : The data series to evaluate, defaults to low
persist (bool) : A boolean indicating whether to retain the last value outside of premarket hours, defaults to true
Returns: The lowest value during the current premarket trading session, or na if the timeframe is not suitable
postmarket_session_high(source, persist)
Returns the highest value of the specified source during the current postmarket trading session
Parameters:
source (float) : The data series to evaluate, defaults to high
persist (bool) : A boolean indicating whether to retain the last value outside of postmarket hours, defaults to true
Returns: The highest value during the current postmarket trading session, or na if the timeframe is not suitable
postmarket_session_low(source, persist)
Returns the lowest value of the specified source during the current postmarket trading session
Parameters:
source (float) : The data series to evaluate, defaults to low
persist (bool) : A boolean indicating whether to retain the last value outside of postmarket hours, defaults to true
Returns: The lowest value during the current postmarket trading session, or na if the timeframe is not suitable
weekly_high(source)
Returns the highest value of the specified source during the current weekly session. Can fail on lower timeframes.
Parameters:
source (float) : The data series to evaluate, defaults to high
Returns: The highest value during the current weekly session, or na if the timeframe is not suitable
weekly_low(source)
Returns the lowest value of the specified source during the current weekly session. Can fail on lower timeframes.
Parameters:
source (float) : The data series to evaluate, defaults to low
Returns: The lowest value during the current weekly session, or na if the timeframe is not suitable
monthly_high(source)
Returns the highest value of the specified source during the current monthly session. Can fail on lower timeframes.
Parameters:
source (float) : The data series to evaluate, defaults to high
Returns: The highest value during the current monthly session, or na if the timeframe is not suitable
monthly_low(source)
Returns the lowest value of the specified source during the current monthly session. Can fail on lower timeframes.
Parameters:
source (float) : The data series to evaluate, defaults to low
Returns: The lowest value during the current monthly session, or na if the timeframe is not suitable
yearly_high(source)
Returns the highest value of the specified source during the current yearly session. Can fail on lower timeframes.
Parameters:
source (float) : The data series to evaluate, defaults to high
Returns: The highest value during the current yearly session, or na if the timeframe is not suitable
yearly_low(source)
Returns the lowest value of the specified source during the current yearly session. Can fail on lower timeframes.
Parameters:
source (float) : The data series to evaluate, defaults to low
Returns: The lowest value during the current yearly session, or na if the timeframe is not suitable