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

파인 라이브러리

트레이딩뷰 정신에 따라 오써는 이 파인 코드를 오픈 소스 라이브러리로 퍼블리쉬하여 당사 커뮤니티의 다른 파인 프로그래머들이 쓸 수 있도록 하였습니다. 오써에게 찬사를! 여러분은 이 라이브러리를 프라이빗 또는 오픈 소스 퍼블리케이션에 쓸 수 있지만 퍼블리케이션에 재사용은 하우스룰을 따릅니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

이 라이브러리를 쓰시겠습니까?

텍스트를 클립보드에 카피한 뒤 님의 스크립트에 붙여 넣기.