peacefulLizard50262

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

Pine腳本庫

本著真正的TradingView精神,作者將此Pine代碼以開源腳本庫發布,以便我們社群的其他Pine程式設計師可以重用它。向作者致敬!您可以私下或在其他開源出版物中使用此庫,但在出版物中重用此代碼受網站規則約束。

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。

想使用這個腳本庫嗎?

複製以下行並將其黏貼到您的腳本中。