alexgrover

Narrow Bandpass Filter

In technical analysis most bandpass filters like the MACD, TRIX, AO, or COG will have a non-symmetrical frequency response, in fact, this one is generally right-skewed. As such these oscillators will not fully remove lower and higher frequency components from the input signal, the following indicator is a bandpass filter with a more symmetrical frequency response with the possibility to have a narrow bandwidth, this allows the indicator to potentially isolate sinusoids from the input signal.

Indicator & Settings

The filter is calculated via convolution, if we take into account that the frequency response of a filter is the Fourier transform of its weighting function we can deduce that we can get a narrow response by using a sinusoid sin(2𝛑nf) as the weighting function, with the peak of the frequency response being equal to f, this makes the filter quite easy to control by the user, as this one can choose the frequency to be isolated. The length of the weighting function controls the bandwidth of the frequency response, with a higher length returning an ever-smaller frequency response width.

In the indicator settings the "Cycle Period" determine the period of the sinusoid used as a weighting function, while "Bandwidth" determine the filter passband width, with higher values returning a narrower passband, this setting also determine the length of the convolution, because the sum of the weights must add to 0 we know that the length of the convolution must be a multiple of "Cycle Period", so the length of the convolution is equal to "Cycle Period × Bandwidth".

Finally, the windowing option determines if a window is applied to the weighting function, a weighting function allow to remove ripples in the filter frequency response


Above both indicators have a Cycle period of 100 and a Bandwidth of 4, we can see that the indicator with no windowing don't fully remove the trend component in the price, this is due to the presence of ripples allowing lower frequency components to pass, this is not the case for the windowed version.

In theory, an ultra-narrow passband would allow to fully isolate pure sinusoids, below the cycle period of interest is 20


using a bandwidth equal to 10 allow to retain that sinusoid, however, note that this sinusoid is subject to phase shift and that it might not be a dominant frequency in the price.


Check out the indicators we are making at luxalgo: www.tradingview.com/u/LuxAlgo/
Mã nguồn mở

Với tinh thần TradingView, tác giả của tập lệnh này đã xuất bản nó dưới dạng mã nguồn mở, vì vậy các nhà giao dịch có thể hiểu và xác minh nó. Chúc mừng tác giả! Bạn có thể sử dụng mã này miễn phí, 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 nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

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 tập lệnh này trên biểu đồ?