OPEN-SOURCE SCRIPT

Who doesn't like smooth things? I'd like a smooth market price for christmas! But i can't get it, instead its so noisy...so you apply a filter to smooth it, such filters are called low-pass filters, they smooth and its great but they have lag, so nobody really use them, but they are pretty to look at.

Its on a childish note that i will introduce this indicator, so what it is all about? I propose a new FIR filter using a blackman function as filter kernel for financial time-series smoothing, do you prefer the childish tone ? Fear not its surprisingly easy!

The blackman function look like a bell shaped curve, look:

The blackman function will produce such curve. This function is called a cosine sum function because she is based on the sum of cosine functions, here only 2.

Originally you use this function for windowing , what does it means? In signal processing you have a function called

Above the optimal low pass filter frequency response.

However the sync function has no ending values and goes on forever, therefore we can't use it for convolution, expect if we apply windowing. Filters using windowing are called windowed-sinc filters, i will describe the procedure below :

1 - Create a sync function = sin(pi*n)/(pi*n)

2 - Truncate it = I only keep the first

This create a abrupt end, the frequency of a filter using step 1 as kernel would contain ripples in the pass band and stop band, this is bad! The frequency response would look like this :

3 - I multiply my values of step 2 by a window function, it can the blackman window, i no longer have an abrupt end, its smooth!

The frequency response of the filter using this kernel would no longer have ripples! This is the power of windowing functions.

Here we are not using such thing, but we could in the future. Here instead we use the blackman function as filter kernel, because this function is bell shaped this mean that the filter will certainly be smooth (symmetrical weighting is a rule of thumb for kernels when we want really smooth filters).

This filter is quite smooth, unlike the gaussian filter this filter give less weights to recent and past values, this is because the blackman function has fatter tails than the gaussian one. I could make a comparison of both, however they are quite alike, if you often use a gaussian filter its up to you to decide which one you prefer.

The filter can do a better job than the moving average when it comes to preserve the frequency components that constitute the cycles/trend.

We can see that the filter has a greater performance when it comes to keep the shape of the market price, thus it has a slightly better fit.

Ok so in this post you learned a bit about the sync function and windowing, those are basic subjects in signal processing, they allow us to approximate the filter with the ideal frequency response, i also showed you that those windowing function could be used as kernel and that they where pretty smooth on their own, there are many others, but the one i prefer is the blackman windowing function.

I know what you are thinking, "we want trailing stops, alerts, colors, arrows!", and i understand you pal, but sometimes its cool to take a break from all this stuff. However i can tell that i'am working on a side project that aim to estimate rolling maximum/minimum as fast as possible, any experiments will be published here, and i can ensure you that those indicators will make your day quite brighter, we will see that soon.

I hope you learned something from this post! I'am a bit tired

Thanks for reading !

Check out the indicators we are making at luxalgo: tradingview.com/u/LuxAlgo/

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.