OPEN-SOURCE SCRIPT

Truncated Bandpass Filter and Bandpass Filter - Dr. John Ehlers

With the arrival of the blessed gifts of arrays from TV, I now present the REAL "Truncated Bandpass Filter" indicator employing PSv4.0 upon initial release, originally formulated by the magnificent mathemagician Dr. John Ehlers for TASC - July 2020 Traders Tips. Don't be bamboozled by the other incorrect truncated bandpass filters found on TV, those published with an erroneous haste that preceded Pine array availability. More information about these bandpass filters can be acquired with a simple search for this indicator's white paper, entitled "TRUNCATED INDICATORS by John F. Ehlers", on his site in the educational reference section.

This actually contains two indicators, one being the truncated bandpass, the other being a two pole bandpass which is also found in my Voss implementation. The two pole bandpass is primarily for comparison of both types, but as you can see, they share common code within both, one being truncated and the other not. I modified Ehlers' original truncation formulation by allowing the capability to alter the truncation period using two distinct methods. I will explain very briefly that the purpose of a truncated "infinite impulse response" filter is to dampen it's response. Truncation techniques aren't limited to only bandpass filters, "some" other IIR filters, but not all, may benefit from this as well.

Lastly this is a miniature starter lesson by example of how the new native Pine array functions may be used, along with other various methods such as `var` to improve computational efficiency on the cloud servers. Yep, native Pine arrays just doubled the "Power of Pine" by exponential magnitudes of power into the dimension of what I would now term as the "Immense Power of Pine". The next generation capability of programming extremely advanced indicators has now successfully arrived on mothership Earth, right on TradingView's front lawn. Who would of known?? This is brought to you in part by the devoted voluntary efforts of the most skilled poetic programmers on TV, the likes of which most extraterrestrial alien programmers would fear. Ladies and Gents, YOU KNOW WHO YOU ARE. Wink, wink!

NOTICE: You have absolute freedom to use this source code any way you see fit within your new Pine projects. You don't have to ask for my permission to reuse these functions in your published scripts, simply because I have better things to do than answer requests for the reuse of the tbpf() and bpf() functions. Sufficient accreditation regarding this script and compliance with "TV's House Rules" regarding code reuse, is as easy as copying the functions in their entirety as is. Fair enough? Good!

Features List Includes:
Dark Background - Easily disabled in indicator Settings->Style for "Light" charts or with Pine commenting
AND a few more... Why list them, when you have the source code to explore!

When available time provides itself, I will consider your inquiries, thoughts, and concepts presented below in the comments section, should you have any questions or comments regarding this indicator. When my indicators achieve more prevalent use by TV members, I may implement more ideas when they present themselves as worthy additions. Have a profitable future everyone!
arraybandpassbandpassfilterCentered OscillatorsiirOscillatorstruncated

Open-source script

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.

Want to use this script on a chart?

Disclaimer