Question regarding Bandpass Filter Harmonic

madeinnyc

Member
I have a question on the BandpassFilter found in TOS, specifically on the use of a Harmonic in the inputs. This input is noted twice in the code block as (Length/Harmonic).
What I'm trying to learn, is the Harmonic a function or some type of reserve word that contains additional code not visible? The word Harmonic has unique applications as it relates to the overall codes behavior. Otherwise, you could just replace Harmonic with whatever and set it as an input to select a number value. But I'm sure there's code behind the word Harmonic and that's what I'm trying to find. Any guidance is appreciated.
 
Nope. Harmonic is not a magic word. It is not function.
It is just the name that this script gives that input.
Feel free to change it to christmas or anything else.
The input needs a name and you can call it anything you wish.

In this script that input is being used as an amplifier. It defaults to 1; so it isn't doing anything at the default.
Ruby:
#
# TD Ameritrade IP Company, Inc. (c) 2019-2023
#

declare lower;

input length = 20;
input bandwidth = 0.1;
input harmonic = 1;

def beta1 = Cos(2 * Double.Pi / (length / harmonic));
def gamma1 = Cos(bandwidth * 2 * Double.Pi / (length / harmonic));
def alpha1 = 1 / gamma1 - Sqrt(1 / Sqr(gamma1) - 1);
def bandpass = if IsNaN(close + close[2]) then 0 else (1 - alpha1) * (close - close[2]) / 2 + beta1 * (1 + alpha1) * bandpass[1] - alpha1 * bandpass[2];

plot BandpassFilter = bandpass;
plot ZeroLine = 0;

BandpassFilter.SetDefaultColor(GetColor(2));
ZeroLine.SetDefaultColor(GetColor(7));
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
253 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top