alexgrover

Hybrid Convolution Filter

Introduction

Today i propose an hybrid filter that use a classical FIR architecture while using recursion. The proposed method aim to reduce the lag generated by fir filters. This particular filter is a sine weighted moving average, but you can change it since the indicator is built with the custom filter template (1). Even if it use recursion it still is a FIR filter since the impulse response is finite.

The Indicator


In red the hybrid swma and in blue the classic swma of both the same period. The difference can be seen.

The switch between the input price and the past values of the previous convolution values is made by using exponential averaging, the window function is the same as f(x) in the code.

Any filter can use this architecture, the indicator is built around the custom fir template, see (1)

Conclusion

I presented a FIR filter using recursion in its calculation, the integration is made with respect to the proposed template, therefore any user can simply modify f(x) to have different filter without the need to make any change. However curious users might want to change the window function of the exponential averager, in order to do so change sgn = f(i/length) in line 11 for sgn = fun(i/length) where fun is your custom function, make sure to add it at the start of the script where all the other functions declarations are.

Thanks for reading !

(1)


Check out the indicators we are making at luxalgo: www.tradingview.com/u/LuxAlgo/
Script de código aberto

Dentro do verdadeiro espírito TradingView, o autor deste script publicou ele como um script de código aberto, para que os traders possam compreender e checar ele. Um viva ao autor! Você pode usá-lo gratuitamente, mas a reutilização deste código em uma publicação é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.

Quer usar esse script no gráfico?