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

Thư viện Pine

Với tinh thần TradingView thực sự, tác giả đã xuất bản mã Pine này như một thư viện mã nguồn mở để các lập trình viên Pine khác từ cộng đồng của chúng tôi có thể sử dụng lại nó. Chúc mừng tác giả! Bạn có thể sử dụng thư viện này một cách riêng tư hoặc trong các ấn phẩm mã nguồn mở khác, nhưng việc sử dụng lại mã này trong một ấn phẩm chịu sự điều chỉnh của Nội quy chung.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.

Bạn muốn sử dụng thư viện này?

Sao chép văn bản vào khay nhớ tạm và dán nó vào tập lệnh của bạn.