alexgrover

Blackman Filter - The Smoother The Better

Introduction

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

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.

0.42 - 0.5 * cos(2 * pi * k) + 0.08 * cos(4 * pi * k)

Originally you use this function for windowing , what does it means? In signal processing you have a function called sync function, if you use this function as filter kernel you would get the ideal frequency domain response filter, sometime called brickwall filter, it would be extremely smooth.


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 length points of the sync function.

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).

The Filter

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.

Conclusion

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 (look i'am disappearing !)

Thanks for reading !



즐겨찾기 스크립트에서 빼기 즐겨찾기 스크립트에 넣기
You can check my indicator papers here : https://figshare.com/authors/Alex_Pierrefeu/7339466
you are a genius thank you for work
+1 응답
alexgrover whoostyle
@whoostyle, Thank you a lot for your support :) I hope to still have it when i'll publish more indicators in the future.
응답
Great! With everything you publish I learn something new!! Keep it up!
JD.
+3 응답
@Duyck, I'am glad to hear that, i will maybe talk more about windowing in the future when i will actually use it for making filters, the post would certainly be more descriptive on how it works :)
응답
Effective ,Simple and Pure Vision ,lets get the picture

Thanks Mate

Great Job as Usual...
+1 응답
@ZAQDA, You are welcome and thanks for the support :)
응답
yea i bet you know alot about the black man function anime boy
+1 응답
@gelnd, And what am i supposed to understand here ?
+2 응답
thanks for sharing it, i love it and create a multi lengths,,
응답
alexgrover Mohamed3nan
@Mohamed3nan, Hi, thanks for the support. When publishing a script it is important to know the house rules. In your case you should have asked before publishing the indicator.
+2 응답
홈으로 스탁 스크리너 포렉스 스크리너 크립토 스크리너 이코노믹 캘린더 사용안내 차트 특징 프라이싱 하우스룰(내부규정) 모더레이터 웹사이트 & 브로커 솔루션 위젯 차팅 솔루션 라이트웨이트 차팅 라이브러리 헬프 센터 프렌드 리퍼하기 기능 개발/개선 요청 블로그 & 뉴스 잦은물음 위키 트위터
프로화일 프로화일설정 계정 및 빌링 프렌드 리퍼하기 나의 서포트 티켓 헬프 센터 공개아이디어 팔로어 팔로잉 비밀메시지 채팅 로그아웃