EhlersSuperSmootherFilter

anton

New member
Hi! How to make this indicator show lines from the daily chart to the 1 minute chart ? I added 2 lines as written here
https://usethinkscript.com/threads/converting-indicator-to-multi-timeframe-mtf-in-thinkorswim.8050/,
but it doesn't work-((



input agg = AggregationPeriod.dAY ;
def close = close(period = agg);


input price = close;
input cutoffLength = 10;

assert(cutoffLength > 0, "cutoffLength must be positive: " + cutoffLength);

def a1 = Exp(-Double.Pi * Sqrt(2) / cutoffLength);
def coeff2 = 2 * a1 * Cos(Sqrt(2) * Double.Pi / cutoffLength);
def coeff3 = - Sqr(a1);
def coeff1 = 1 - coeff2 - coeff3;
def filt = if IsNaN(price + price[1]) then filt[1] else coeff1 * (price + price[1]) / 2 + coeff2 * filt[1] + coeff3 * filt[2];

plot SuperSmootherFilter = if !IsNaN(price) then filt else Double.NaN;
SuperSmootherFilter.SetDefaultColor(GetColor(5));


 
Solution
Your code has most of the right things, just not in the right places: (on second lo0k it might have worked, just been off the chart... but read on...

Code:
input agg = AggregationPeriod.dAY ;

def price = close(period = agg);
input cutoffLength = 10;

assert(cutoffLength > 0, "cutoffLength must be positive: " + cutoffLength);

def a1 = Exp(-Double.Pi * Sqrt(2) / cutoffLength);
def coeff2 = 2 * a1 * Cos(Sqrt(2) * Double.Pi / cutoffLength);
def coeff3 = - Sqr(a1);
def coeff1 = 1 - coeff2 - coeff3;
def filt = if IsNaN(price + price[1]) then filt[1] else coeff1 * (price + price[1]) / 2 + coeff2 * filt[1] + coeff3 * filt[2];

plot SuperSmootherFilter = if !IsNaN(price) then filt else Double.NaN...

mashume

Well-known member
VIP
Lifetime
Your code has most of the right things, just not in the right places: (on second lo0k it might have worked, just been off the chart... but read on...

Code:
input agg = AggregationPeriod.dAY ;

def price = close(period = agg);
input cutoffLength = 10;

assert(cutoffLength > 0, "cutoffLength must be positive: " + cutoffLength);

def a1 = Exp(-Double.Pi * Sqrt(2) / cutoffLength);
def coeff2 = 2 * a1 * Cos(Sqrt(2) * Double.Pi / cutoffLength);
def coeff3 = - Sqr(a1);
def coeff1 = 1 - coeff2 - coeff3;
def filt = if IsNaN(price + price[1]) then filt[1] else coeff1 * (price + price[1]) / 2 + coeff2 * filt[1] + coeff3 * filt[2];

plot SuperSmootherFilter = if !IsNaN(price) then filt else Double.NaN;
SuperSmootherFilter.SetDefaultColor(GetColor(5));

You can't do input statements with variables in them, which is why it doesn't say input price = close(period = agg).
Also, please be aware that redefining close as a local variable:
Code:
def close = close(period = agg);
can make it very difficult to diagnose problems since you're never sure whether close means current period or something else. Always safer to define it as something other than a built-in, so...
Code:
def secondary_agg_close = close(period = agg);

Good clean code is easy to debug.

If it still isn't displaying anything, try setting the number of days on your chart to more than 1. And check whether "fit studies" is checked. The first time I tried it, it was off the top of the chart by a lot and I couldn't "see" the line.

Happy Trading,
-mashume
 
Solution

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.
Top