• Get $40 off VIP by signing up for a free account! Sign Up

LazyBear's Universal Oscillator for Thinkorswim


Well-known member

Another TradingView port...Looking forward to thoughts, feedback, backtests, etc...

Here's some additional information regarding the Universal Oscillator, courtesy of LazyBear:

Universal Oscillator by Mr. Ehlers is an evolution of his SuperSmoother filter. The new indicator follows the swings in price without introducing extra delay.

It is controlled through one single input – the band edge – which basically is frequency. The smaller it is set, the less lag there is, but you may see lot of whipsaws. Built-in automatic gain control normalizes the output to vary between the range of -1 to +1.

Mr. Ehlers suggests a straightforward system:
- Buy when long-term Universal Oscillator crosses above zero
- Sell when long-term Universal Oscillator crosses below zero

# filename: _Universal_Oscillator_LB_
# source: https://www.tradingview.com/script/ieFYbVdC-Ehlers-Universal-Oscillator-LazyBear/

# Original idea and execution:
# Ehlers Universal Oscillator
# Code by LazyBear

# initial port by netarchitech
# 2019.11.05

declare lower;

input bandedge = 20;
input showHistogram = yes;
input showMA = no;
input lengthMA = 9;
input PaintBars = yes;
input price = close;

def whitenoise = (close - close[2])/2;
def a1 = expaverage(-1.414 * 3.14159 / bandedge);
def b1 = 2.0 * a1 * cos(1.414 * 180 /bandedge);
def c2 = b1;
def c3 = -a1 * a1;
def c1 = 1 - c2 - c3;

def filt = c1 * (whitenoise + (whitenoise[1]))/2 + c2 * (filt[1]) + c3 * (filt[2]);

def filt1 = if totalsum(1) == 0 then 0 else if totalsum(1) == 2 then c2 * filt1[1] else if totalsum(1) == 3 then c2 * filt1[1] + c3 * (filt1[2]) else filt;

def pk = if totalsum(1) == 2 then .0000001 else if absvalue(filt1) > pk[1] then absvalue(filt1) else 0.991 * pk[1];

def denom = if pk==0 then -1 else pk;

def euo = if denom == -1 then euo[1] else filt1/pk;

def euoMA = expaverage(euo, lengthMA);

plot zeroLine = 0;

plot diff = if showHistogram then euo else double.nan;
     diff.DefineColor("Positive and Up", Color.UPTICK);
     diff.DefineColor("Positive and Down", Color.UPTICK);
     diff.DefineColor("Negative and Down", Color.DOWNTICK);
     diff.DefineColor("Negative and Up", Color.DOWNTICK);
     diff.AssignValueColor(if diff >= 0 then if diff > diff[1] then diff.color("Positive and Up") else diff.color("Positive and Down") else if diff < diff[1] then diff.color("Negative and Down") else diff.color("Negative and Up"));

plot ehlers_universal_oscillator = euo;

plot showMovAvg = if showMA then euoMA else double.nan;

AssignPriceColor(if PaintBars then (if euo >= 0 then Color.UPTICK else Color.DOWNTICK) else Color.CURRENT);

Good Luck and Good Trading :)
Last edited:

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

@netarchitech This is a very interesting study...It looks like the bars also paint towards a trend and the oscillator could be used with conjunction with another SuperTrend type indicator...IF both the SuperTrend and the Oscillator were to go in the same direction a possible entry could be used as a stronger confirmation signal. I think I will test this study out tomorrow and see IF the Oscillator or the candles repaint more or less than other SuperTrend indicators that I used previously.

EDIT: This study ALSO seems to be a very good exit indicator as it hits faster than even the Stochastic Momentum Index. I'd like to see if the candles or the oscillator repaints quickly or not and how that will affect false signals...I also noticed that on the oscillator there is a moving average...I like this idea as when it crosses the ZERO line it indicates the trend...What I am wondering is if paired with another moving average of the same type just a shorter length would speed up the trend recognition or confirmation IF a crossover of such moving averages were to occur before the actual candles crossed the ZERO line.

EDIT 2: Just realized that there is in fact a second moving average called Ehlers Universal that was not check in...I guess that answers my question above. Can you add breakout signals when those two crossover? I have noticed that there are instances where the histograms bars DO NOT appear especially on what appears to be a volatile move when the bars cross the ZERO line...The candles sticks on the upper study still paint in the direction of the trend but not the oscillator. This would be important especially if one were to use a different type of a SuperTrend on the upper study and confirm the entry or exit with the oscillator on the lower study...

IF this is not a super sensitive indicator that repaints all the time...this might be a new favorite contender. Nice find!

EDIT 3: This indicator seems to work even better once you change the colors of the histogram to the same color format of the MACD with the color strength histogram bars assigned. This indicator is keeping up with ROKU...so its definitely worth further testing in the morning in live market conditions. With less volatile stocks this indicator will work great if it can keep up with ROKU without throwing many false signals.

EDIT 4: On a second thought...do you think it would be possible to combine the Stochastic Momentum Index indicator with the Ultimate Oscillator Histogram to create a somewhat MACD like indicator with the breakout signals on the Stochastic Momentum Index...? and possibly secondary breakout signals on the two moving averages on the oscillator but not incorporating the actual moving average lines of the ultimate oscillator? The OB/OS lines would also be cool to have in order to fully take advantage of the Stochastic Momentum Index...the ZERO line that you added to the SMI version could be optional...but not necessary as key would be to look for the SMI cross over as well as the bars heading below the ZERO line on the Ultimate Oscillator.

I really like the Stochastic Momentum Index...and this is a potential contender...so why not combine the two if possible and save space in the lower studies?

I am watching both side by side and I like the Moving average crosses of the Stochastic Moment Index more BUT the histogram on the Ultimate Oscillator is also a key feature especially when using it with a secondary SuperTrend type indicator. If you could incorporate both of these with all the features and allow the end user to select what they want in the study that would be ideal. Just a thought but I think if you could do this it would be probably the Ultimate Exit Indicator out there.
Last edited:
So many oscillators. I tested and tuned and retested them over and over again and cant make up my mind which ones I want keep

What we want from oscillator is :
Show trend
Show chop
Clear signals in transition between phases

One of these days I gonna do a final test of all those damn oscillators and pick one only one I want use:
Lagueree FE RSI

And of course the old Staples :
  • Haha
Reactions: MBF
Hey there @HighBredCloud Thanks for the excellent and comprehensive analysis :) I will start to investigate and see if I can incorporate the modifications you suggest...

Below please find a prototype screenshot of the SMI DSS and the EUO merged together...looks great BUT there is the scaling issue again :( While they are both zero bound, the SMI DSS ranges from 40 to -40, whereas the EUO ranges from 1 to -1...

Will require further investigation to see if this ultimately be feasible...

Well renormalizing between range bound value is trivial - just multiply by most common denominator
@skynetgen Thanks for your recent comments...

Well renormalizing between range bound value is trivial - just multiply by most common denominator

I just discovered that, but, alas, I am just a noob when it comes to many things you and other advanced scripters already know. With that said, I appreciate the feedback :cool:
@HighBredCloud Sorry to hear about your troubles today...I'm glad you've pinpointed the likely suspect :)

I've had some of my own with a particular indicator I've used for many a year until recently...It starts and stops all day long...No reason, just off and on...TOS support had me tear down my installation to bare "metal" and yet it still persists...They want to re-install the video drivers, but I'm dealing with Nvidia...meaning if you're lucky enough to find drivers that work (I have), DON'T mess with them...Needless to say, I'm not going there for a particular indicator...

In other news...I'm wrapping up another LazyBear TradingView port...this is the one that incorporates the EhlersSuperSmootherFilter...After that I'm looking to revisit PercentR_MAC and see if I can smooth out PercentR...As always, I'll keep you apprised of any/all developments...
Hey there @HighBredCloud ...
Exactly not worth all this headache for just one indicator.

I hear ya...

I am running 4 32 in monitors tho...

WOW! I thought I was kickin' it running 3 monitors...You're running MISSION CONTROL! :ROFLMAO:

I would be really curious to see when you implement the EhlersSuperSmootherFilter into PercentR_MAC...

That's next on the agenda...I have some ideas, but it's just a wee bit early to say if I'll be successful...Like I've said before, I'll keep bangin' my head against the wall until I get through or around where I'm looking to go...

Did you see the Larry Williams ProGo indicator code that I posted?

@HighBredCloud I apologize for not thanking you much earlier for forwarding that to me...I really appreciate the "support" :) As I believe I've said before, Teamwork is the key! I think our collaboration is starting to bear some worthy fruit...Thanks for being a most excellent teammate! :cool:
Since this is already a bounder oscillator between -1 and 1, adding a cloud at those defined OB/OS levels will not yield a cloud. Probably best to do something like normalize the scale from 0 to 100 and then set the OB/OS to 70/30 or 80/20 or such like
@tomsk Thanks for the tip :) Honestly, I haven't had much success trying to normalize scales...Any additional tips would be greatly appreciated...
I'll let you pro's figure this out...I'm ONLY good for testing and making lives harder on those trying to code to my requests. First step is acceptance right?
@12matthew09 I see what you're talking about...Thanks for the screen shot...I have a number of other issues to attend to first, but I'll take another look when afterwards...

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
192 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.