PINE LIBRARY

time_and_session

A 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
rangetimesessions

파인 라이브러리

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


또한 다음에서도:

면책사항