LTI_Filters

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.
Biblioteca Pine
Siguiendo fielmente el espíritu de TradingView, el autor ha publicado este código Pine como una biblioteca de código, permitiendo que otros programadores de Pine en nuestra comunidad puedan volver a utilizarlo. ¡Un brindis por el autor! Puede utilizar esta biblioteca de forma privada o en otras publicaciones de código abierto, pero tenga en cuenta que la reutilización de este código en publicaciones se rige por las Normas internas.
Exención de responsabilidad
Biblioteca Pine
Siguiendo fielmente el espíritu de TradingView, el autor ha publicado este código Pine como una biblioteca de código, permitiendo que otros programadores de Pine en nuestra comunidad puedan volver a utilizarlo. ¡Un brindis por el autor! Puede utilizar esta biblioteca de forma privada o en otras publicaciones de código abierto, pero tenga en cuenta que la reutilización de este código en publicaciones se rige por las Normas internas.