Time

Utilities for measuring time.
bar() Gets the number of milliseconds per bar.
Added:
date(datetime) Gets the start of the day for the provided time value.
Parameters:
datetime: The time of day to acquire the date from.
Returns: The number of milliseconds representing the date for the given value.
Added:
timeOfDay(datetime) Gets milliseconds from the start of the day.
Parameters:
datetime: The date/time to acquire the time of day from.
Returns: The number of milliseconds representing time of day.
Added:
spanToLen(timespan, type, sessionMinutes)
Returns the number (float) bars that represents the timespan provided.
Parameters:
timespan: The number of units to convert to bar count.
type: The type of units to measure. ('Bar', 'Minute' or 'Day')
sessionMinutes: Optional override for the number of minutes per session. (Default: Regular = 390, Extended = 1440)
Returns: The number bars that represents the timespan provided.
spanToIntLen(timespan, type)
Returns the number (int) bars that represents the timespan provided.
Parameters:
timespan: The number of units to convert to bar count.
type: The type of units to measure. ('Bar', 'Minute' or 'Day')
Returns: The number bars that represents the timespan provided.
Updated:
spanToLen(timespan, unit, sessionMinutes)
Returns the number (float) bars that represents the timespan provided.
Parameters:
timespan (simple float): The number of units to convert to bar count.
unit (simple TimeUnit): The type of units to measure as a TimeUnit enum ('Bars', 'Seconds', 'Minutes', 'Days').
sessionMinutes (simple int): Optional override for the number of minutes per session. (Default: Regular = 390, Extended = 1440)
Returns: The number bars that represents the timespan provided.
spanToIntLen(timespan, unit)
Returns the number (int) bars that represents the timespan provided.
Parameters:
timespan (simple float): The number of units to convert to bar count.
unit (simple TimeUnit): The type of units to measure as a TimeUnit enum ('Bars', 'Seconds', 'Minutes', 'Days').
Returns: The number bars that represents the timespan provided.
Updated:
spanToLen(timespan, unit, sessionMinutes)
Returns the number (float) bars that represents the timespan provided.
Parameters:
timespan (simple float): The number of units to convert to bar count.
unit (simple Unit): The type of units to measure as a Unit enum ('Bars', 'Seconds', 'Minutes', 'Days').
sessionMinutes (simple int): Optional override for the number of minutes per session. (Default: Regular = 390, Extended = 1440)
Returns: The number bars that represents the timespan provided.
spanToIntLen(timespan, unit)
Returns the number (int) bars that represents the timespan provided.
Parameters:
timespan (simple float): The number of units to convert to bar count.
unit (simple Unit): The type of units to measure as a Unit enum ('Bars', 'Seconds', 'Minutes', 'Days').
Returns: The number bars that represents the timespan provided.
Removed Week, Month, Year options as they will be subjectively inaccurate.
Added:
getDefaultSessionMinutes()
Returns the default session length in minutes based on syminfo.type and syminfo.session
Returns: Integer session length in minutes (e.g. 390, 1380, 1440)
Biblioteca Pine
Siguiendo fielmente el espíritu de TradingView, el autor ha publicado este código Pine como una biblioteca de código, permitiendo que otros programadores de Pine en nuestra comunidad puedan volver a utilizarlo. ¡Un brindis por el autor! Puede utilizar esta biblioteca de forma privada o en otras publicaciones de código abierto, pero tenga en cuenta que la reutilización de este código en publicaciones se rige por las Normas internas.
Exención de responsabilidad
Biblioteca Pine
Siguiendo fielmente el espíritu de TradingView, el autor ha publicado este código Pine como una biblioteca de código, permitiendo que otros programadores de Pine en nuestra comunidad puedan volver a utilizarlo. ¡Un brindis por el autor! Puede utilizar esta biblioteca de forma privada o en otras publicaciones de código abierto, pero tenga en cuenta que la reutilización de este código en publicaciones se rige por las Normas internas.