# Narrow Bandpass Filter

2223 visningar
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.

Skript med en öppen källkod

I sann TradingView-anda har författaren till detta skript publicerat det som öppen källkod, så att handlare kan förstå och verifiera det. Skål för författaren! Du kan använda den gratis men återanvändning av den här koden i en publikation regleras av våra Ordningsregler. Du kan göra den till favorit för att använda den i ett diagram.

Vill du använda det här skriptet i ett diagram?
Patreon: https://www.patreon.com/alexgrover

You can also check out some of the indicators I made for luxalgo : https://www.tradingview.com/u/LuxAlgo/#published-scripts

## Kommentarer

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
Svara
ICEKI
@ICEKI, Thx for the feedback, glad to hear the explanation is easy to understand :)
Svara
thanks very much for this work, this is pure gold!
Svara
Great, thanks!. Will star playing with it.
Svara
High or very high math level for me, thanks for your elegant presentation
Svara
Thank you sir
Svara
very slick Alex- thank you !!
Svara
I really love your scripts man. I really think you're on the right track with the standards of measure you are identifying
Svara
kurtsmock
@kurtsmock, I'm really glad to hear it :) I hope you'll also love my future works
Svara
Thank you :)
Svara