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 !



Gỡ bỏ khỏi Script Ưa thích Thêm vào Script Ưa thích
You can check my indicator papers here : https://figshare.com/authors/Alex_Pierrefeu/7339466
you are a genius thank you for work
+1 Phản hồi
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.
Phản hồi
Great! With everything you publish I learn something new!! Keep it up!
JD.
+3 Phản hồi
@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 :)
Phản hồi
Effective ,Simple and Pure Vision ,lets get the picture

Thanks Mate

Great Job as Usual...
+1 Phản hồi
@ZAQDA, You are welcome and thanks for the support :)
Phản hồi
yea i bet you know alot about the black man function anime boy
+1 Phản hồi
@gelnd, And what am i supposed to understand here ?
+2 Phản hồi
thanks for sharing it, i love it and create a multi lengths,,
Phản hồi
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 Phản hồi
Trang chủ Bộ lọc cổ phiếu Bộ lọc Forex Bộ lọc Tiền điện tử Lịch kinh tế Shows Cách thức hoạt động Tính năng Biểu đồ Giá Quy tắc Áp dụng Người điều hành Giải pháp cho Website & Nhà môi giới Widget Giải pháp biểu đồ Thư viện Biểu đồ Lightweight Trung tâm Trợ giúp Giới thiệu bạn Yêu cầu tính năng Blog & Tin tức Câu hỏi thường gặp Wiki Twitter
Hồ sơ Tùy chỉnh Hồ sơ Tài khoản và Thanh toán Giới thiệu bạn Ticket Hỗ trợ của tôi Trung tâm Trợ giúp Các ý tưởng đã đăng Người theo dõi Đang theo dõi Tin nhắn riêng Trò chuyện Đăng xuất