Linear Time-Invariant (LTI) filters are fundamental tools in signal processing that operate with consistent behavior over time and linearly respond to input signals. They are crucial for analyzing and manipulating signals in various applications, ensuring the output signal's integrity is maintained regardless of when an input is applied or its magnitude. The Windowed Sinc filter is a specific type of LTI filter designed for digital signal processing. It employs a Sinc function, ideal for low-pass filtering, truncated and shaped within a finite window to make it practically implementable. This process involves multiplying the Sinc function by a window function, which tapers off towards the ends, making the filter finite and suitable for digital applications. Windowed Sinc filters are particularly effective for tasks like data smoothing and removing unwanted frequency components, balancing between sharp cutoff characteristics and minimal distortion. The efficiency of Windowed Sinc filters in digital signal processing lies in their adept use of linear algebra, particularly in the convolution process, which combines input data with filter coefficients to produce the desired output. This mathematical foundation allows for precise control over the filtering process, optimizing the balance between filtering performance and computational efficiency. By leveraging linear algebra techniques such as matrix multiplication and Toeplitz matrices, these filters can efficiently handle large datasets and complex filtering tasks, making them invaluable in applications requiring high precision and speed, such as audio processing, financial signal analysis, and image restoration.

Library "LTI_Filters"

offset(length, enable)
  Calculates the time offset required for aligning the output of a filter with its input, based on the filter's length. This is useful for centered filters where the output is naturally shifted due to the filter's operation.
  Parameters:
    length (simple int): The length of the filter.
    enable (simple bool): A boolean flag to enable or dissable the offset calculation.
  Returns: The calculated offset if enabled; otherwise, returns 0.

lti_filter(filter_type, source, length, prefilter, centered, fc, window_type)
  General-purpose Linear Time-Invariant (LTI) filter function that can apply various filter types to a data series. Can be used to apply a variety of LTI filters with different characteristics to financial data series or other time series data.
  Parameters:
    filter_type (simple string): Specifies the type of filter. ("Sinc", "SMA", "WMA")
    source (float): The input data series to filter.
    length (simple int): The length of the filter.
    prefilter (simple bool): Boolean indicating whether to prefilter the input data.
    centered (simple bool): Determines whether the filter coefficients are centered.
    fc (simple float): Filter cutoff. Expressed like a length.
    window_type (simple string): Type of window function to apply. ("Hann", "Hamming", "Blackman", "Triangular", "Lanczos", "None")
  Returns: The filtered data series.

lti_sma(source, length, prefilter)
  Applies a Simple Moving Average (SMA) filter to the data series. Useful for smoothing data series to identify trends or for use as a component in more complex indicators.
  Parameters:
    source (float): The input data series to filter.
    length (simple int): The length of the SMA filter.
    prefilter (simple bool): Boolean indicating whether to prefilter the input data.
  Returns: The SMA-filtered data series.

lti_wma(source, length, prefilter, centered)
  Applies a Weighted Moving Average (WMA) filter to a data series. Ideal for smoothing data with emphasis on more recent values, allowing for dynamic adjustments to the weighting scheme.
  Parameters:
    source (float): The input data series to filter.
    length (simple int): The length of the WMA filter.
    prefilter (simple bool): Boolean indicating whether to prefilter the input data.
    centered (simple bool): Determines whether the filter coefficients are centered.
  Returns: The WMA-filtered data series.

lti_sinc(source, length, prefilter, centered, fc, window_type)
  Applies a Sinc filter to a data series, optionally using a window function. Particularly useful for signal processing tasks within financial analysis, such as smoothing or trend identification, with the ability to fine-tune filter characteristics.
  Parameters:
    source (float): The input data series to filter.
    length (simple int): The length of the Sinc filter.
    prefilter (simple bool): Boolean indicating whether to prefilter the input data.
    centered (simple bool): Determines whether the filter coefficients are centered.
    fc (simple float): Filter cutoff. Expressed like a length.
    window_type (simple string): Type of window function to apply. ("Hann", "Hamming", "Blackman", "Triangular", "Lanczos", "None")
  Returns: The Sinc-filtered data series.

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.