OPEN-SOURCE SCRIPT

Variety, Low-Pass, FIR Filter Impulse Response Explorer [Loxx]

Variety Low-Pass FIR Filter, Impulse Response Explorer [Loxx] is a simple impulse response explorer of 16 of the most popular FIR digital filtering windowing techniques. Y-values are the values of the coefficients produced by the selected algorithms; X-values are the index of sample. This indicator also allows you to turn on Sinc Windowing for all window types except for Rectangular, Triangular, and Linear. This is an educational indicator to demonstrate the differences between popular FIR filters in terms of their coefficient outputs. This is also used to compliment other indicators I've published or will publish that implement advanced FIR digital filters (see below to find applicable indicators).

Inputs:
  • Number of Coefficients to Calculate = Sample size; for example, this would be the period used in SMA or WMA
  • FIR Digital Filter Type = FIR windowing method you would like to explore
  • Multiplier (Sinc only) = applies a multiplier effect to the Sinc Windowing
  • Frequency Cutoff = this is necessary to smooth the output and get rid of noise. the lower the number, the smoother the output.
  • Turn on Sinc? = turn this on if you want to convert the windowing function from regular function to a Windowed-Sinc filter
  • Order = This is used for power of cosine filter only. This is the N-order, or depth, of the filter you wish to create.


What are FIR Filters?
In discrete-time signal processing, windowing is a preliminary signal shaping technique, usually applied to improve the appearance and usefulness of a subsequent Discrete Fourier Transform. Several window functions can be defined, based on a constant (rectangular window), B-splines, other polynomials, sinusoids, cosine-sums, adjustable, hybrid, and other types. The windowing operation consists of multipying the given sampled signal by the window function. For trading purposes, these FIR filters act as advanced weighted moving averages.

A finite impulse response (FIR) filter is a filter whose impulse response (or response to any finite length input) is of finite duration, because it settles to zero in finite time. This is in contrast to infinite impulse response (IIR) filters, which may have internal feedback and may continue to respond indefinitely (usually decaying).

The impulse response (that is, the output in response to a Kronecker delta input) of an Nth-order discrete-time FIR filter lasts exactly {\displaystyle N+1}N+1 samples (from first nonzero element through last nonzero element) before it then settles to zero.

FIR filters can be discrete-time or continuous-time, and digital or analog.

A FIR filter is (similar to, or) just a weighted moving average filter, where (unlike a typical equally weighted moving average filter) the weights of each delay tap are not constrained to be identical or even of the same sign. By changing various values in the array of weights (the impulse response, or time shifted and sampled version of the same), the frequency response of a FIR filter can be completely changed.

An FIR filter simply CONVOLVES the input time series (price data) with its IMPULSE RESPONSE. The impulse response is just a set of weights (or "coefficients") that multiply each data point. Then you just add up all the products and divide by the sum of the weights and that is it; e.g., for a 10-bar SMA you just add up 10 bars of price data (each multiplied by 1) and divide by 10. For a weighted-MA you add up the product of the price data with triangular-number weights and divide by the total weight.

What's a Low-Pass Filter?
A low-pass filter is the type of frequency domain filter that is used for smoothing sound, image, or data. This is different from a high-pass filter that is used for sharpening data, images, or sound.

Whats a Windowed-Sinc Filter?
Windowed-sinc filters are used to separate one band of frequencies from another. They are very stable, produce few surprises, and can be pushed to incredible performance levels. These exceptional frequency domain characteristics are obtained at the expense of poor performance in the time domain, including excessive ripple and overshoot in the step response. When carried out by standard convolution, windowed-sinc filters are easy to program, but slow to execute.

The sinc function sinc (x), also called the "sampling function," is a function that arises frequently in signal processing and the theory of Fourier transforms.

In mathematics, the historical unnormalized sinc function is defined for x ≠ 0 by

sinc x = sinx / x

In digital signal processing and information theory, the normalized sinc function is commonly defined for x ≠ 0 by

sinc x = sin(pi * x) / (pi * x)

For our purposes here, we are used a normalized Sinc function

Included Windowing Functions
  • N-Order Power-of-Cosine (this one is really N-different types of FIR filters)
  • Hamming
  • Hanning
  • Blackman
  • Blackman Harris
  • Blackman Nutall
  • Nutall
  • Bartlet Zero End Points
  • Bartlet-Hann
  • Hann
  • Sine
  • Lanczos
  • Flat Top
  • Rectangular
  • Linear
  • Triangular


If you wish to dive deeper to get a full explanation of these windowing functions, see here: https://en.wikipedia.org/wiki/List_of_window_functions

Related indicators
STD-Filtered, Variety FIR Digital Filters w/ ATR Bands [Loxx]
STD-Filtered, Variety FIR Digital Filters w/ ATR Bands [Loxx]


STD/C-Filtered, N-Order Power-of-Cosine FIR Filter [Loxx]
STD/C-Filtered, N-Order Power-of-Cosine FIR Filter [Loxx]


STD/C-Filtered, Truncated Taylor Family FIR Filter [Loxx]
STD/C-Filtered, Truncated Taylor Family FIR Filter [Loxx]


STD/Clutter-Filtered, Kaiser Window FIR Digital Filter [Loxx]
STD/Clutter-Filtered, Kaiser Window FIR Digital Filter [Loxx]


STD/Clutter Filtered, One-Sided, N-Sinc-Kernel, EFIR Filt [Loxx]
STD/Clutter Filtered, One-Sided, N-Sinc-Kernel, EFIR Filt [Loxx]
cardinalsinedigitalfiltereducationalfiniteimpulseresponseFIRfirfilterimpulseresponselowpasspowerofcosineSINC

Mã nguồn mở

Theo tinh thần TradingView thực sự, tác giả của tập lệnh này đã xuất bản dưới dạng nguồn mở để các nhà giao dịch có thể hiểu và xác minh. Chúc mừng tác giả! Bạn có thể sử dụng miễn phí. Tuy nhiên, bạn cần sử dụng lại mã này theo Quy tắc nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?


Public Telegram Group, t.me/algxtrading_public

VIP Membership Info: patreon.com/algxtrading/membership
Ngoài ra, trên:

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