TradingView
alexgrover
Jun 9, 2020 4:10 PM

Narrow Bandpass Filter 

Advanced Micro Devices, Inc.NASDAQ

Description

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.

Comments
ICEKI
Thank You so much Alex as always. I love your details explanation which easy to understand how the functioning. Keep it up my friend <3
alexgrover
@ICEKI, Thx for the feedback, glad to hear the explanation is easy to understand :)
danalec
thanks very much for this work, this is pure gold!
FXPDM
Great, thanks!. Will star playing with it.
azinc
High or very high math level for me, thanks for your elegant presentation
NicoleLomazowLowe
Thank you sir
idrisbengali
very slick Alex- thank you !!
kurtsmock
I really love your scripts man. I really think you're on the right track with the standards of measure you are identifying
alexgrover
@kurtsmock, I'm really glad to hear it :) I hope you'll also love my future works
Pratik_4Clover
Thank you :)
More