Ehlers Truncated BandPass Filter [CC]

Hot off the presses! The Truncated BandPass Filter was created by John Ehlers (Stocks & Commodities July 2020) and this is a much more reactive version of his original bandpass filter. When the indicator rises above 0 then it is an uptrend and when it falls below 0 then it is in a downtrend. Buy when the indicator line is red and sell when it is green.

Let me know if there are other scripts you would like to see me publish or if you want something custom done!
Remove from Favorite Scripts Add to Favorite Scripts


how is it better than original?
cheatcountry greyghost7
@greyghost7, there is a technical error right now with pinescript which isn't allowing me to correct the code. I will update this script as soon as they fix the bug
Here must be ...(1 + s1) * nz(trunc(1))... instead of ...(1 + s1) * nz(trunc(2)).... If you make such correction you get IIR Bandpass Filter not a truncated version.
cheatcountry harkalada31
@harkalada31, This was done on purpose because there is a technical issue with tv that prevents me from showing the correct code
harkalada31 cheatcountry
@cheatcountry, your code is incorrect. The idea of FIR filters, and truncated version of Bandpass Filter is a FIR filter, that you have to use coefficients with every element of the filter. In example with EMA in article this is demonstrated very well. There are only one element of previous values in EMA and that is why you use only one set of coefficients. In bandpass filter there are two such elements BP(1) and BP(2). To get FIR filter from IIR you have to use two set of coefficients. For that purpose Mr Ehlers uses arrays for calculation of truncated version of Bandpass Filter, one for BP(1) and another for BP(2).
Comparing your code with the traders' tips codes isn't the loop part missing ?
cheatcountry sal157011
@sal157011, he uses the loop to populate an array which isn't needed with pinescript
Home Stock Screener Forex Screener Crypto Screener Economic Calendar How It Works Chart Features Pricing Refer a friend House Rules Help Center Website & Broker Solutions Widgets Charting Solutions Lightweight Charting Library Blog & News Twitter
Profile Profile Settings Account and Billing Referred friends Coins My Support Tickets Help Center Ideas Published Followers Following Private Messages Chat Sign Out