PINE LIBRARY

LTI_Filters

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.
filterlinearMATHSINCsmatechindicator

Bibliothèque Pine

Dans le plus pur esprit TradingView, l'auteur a publié ce code Pine en tant que bibliothèque open-source afin que d'autres programmeurs Pine de notre communauté puissent le réutiliser. Bravo à l'auteur! Vous pouvez utiliser cette bibliothèque en privé ou dans d'autres publications à code source ouvert, mais la réutilisation de ce code dans une publication est régie par nos Règles.


Aussi sur:

Clause de non-responsabilité