netarchitech
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
Code:
# 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.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
diff.SetLineWeight(5);
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;
ehlers_universal_oscillator.hide();
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: