NexusFi: Find Your Edge


Home Menu

 





Ehlers Universal Oscillator


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one ebtrader1 with 1 posts (0 thanks)
    2. looks_two punchy123 with 1 posts (0 thanks)
    3. looks_3 trendwaves with 1 posts (1 thanks)
    4. looks_4 nglpx1 with 1 posts (0 thanks)
    1. trending_up 4,471 views
    2. thumb_up 1 thanks given
    3. group 4 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

Ehlers Universal Oscillator

  #1 (permalink)
ebtrader1
east brusnwick
 
Posts: 1 since Nov 2014
Thanks Given: 0
Thanks Received: 0

I found Ehlers has a new oscillator out in Jan 2015 issue of TASC that combines the ssf with gain control.

If anyone has some free time, it would be great if you could convert to thinkscript and post. to save you time, keep in mind the supersmootherfilter is already in the TOS library so you can reference it.

the ssf part is no problem for me to convert to ssf. however, with the gain control, i am having a tough time understanding how to convert 2 of these easylanguage lines. any suggestions?

The lines I am having trouble scripting are:
 
Code
If Currentbar = 1 then 
	Peak = .0000001 ;
If Peak <> 0 then 
	Universal = Filt / Peak ;


I guess the first line is initialization of peak. Do you know how that is done in Thinkscript. The second line has a <>. Do you know what that means and how it is done in thinkscript?

Your help is much appreciated as always. If I can figure out those 2 lines, then I am home free.



Here is the EasyLanguage:

 
Code
_Ehlers_Universal Oscillator (Indicator)

// Universal Oscillator
// (c) 2014 John F. Ehlers
// TASC January 2015
inputs:
	BandEdge( 20 ) ;
variables:
	WhiteNoise( 0 ),
	a1( 0 ),
	b1( 0 ),
	c1( 0 ),
	c2( 0 ),
	c3( 0 ),
	Filt(0),
	Peak(0),
	Universal( 0 ) ;

once
	begin
	if BandEdge <= 0 then
		RaiseRunTimeError( "BandEdge must be > zero" ) ;
	end ;

WhiteNoise = ( Close - Close[2] ) / 2 ;

// SuperSmoother Filter
a1 = ExpValue( -1.414 * 3.14159 / BandEdge ) ;
b1 = 2 * a1 * Cosine( 1.414 * 180 / BandEdge ) ;
c2 = b1 ;
c3 = -a1 * a1 ;
c1 = 1 - c2 - c3 ;
Filt = c1 * ( WhiteNoise + WhiteNoise [1] ) / 2 + 
c2 * Filt[1] + c3 * Filt[2] ;
If Currentbar = 1 then 
	Filt = 0 ;
If Currentbar = 2 then 
	Filt = c1 * 0 * ( Close + Close[1] ) / 2 + c2 * Filt[1] ;
If Currentbar = 3 then 
	Filt = c1 * 0 * ( Close + Close[1] ) / 2 + c2 * Filt[1] +
c3 * Filt[2] ;

// Automatic Gain Control (AGC)
Peak = .991 * Peak[1] ;
If Currentbar = 1 then 
	Peak = .0000001 ;
If AbsValue( Filt ) > Peak then 
	Peak = AbsValue( Filt ) ;
If Peak <> 0 then 
	Universal = Filt / Peak ;
Plot1( Universal ) ;
Plot2( 0 ) ;


if Universal crosses over 0 then
	Alert( "Osc cross over zero line" )
else if Universal crosses under 0 then	
	Alert( "Osc cross under zero line" ) ;


_Ehlers_Universal Oscillator (Strategy)

// Universal Oscillator
// (c) 2014 John F. Ehlers
// TASC January 2015
inputs:
	BandEdge( 20 ) ;
variables:
	WhiteNoise( 0 ),
	a1( 0 ),
	b1( 0 ),
	c1( 0 ),
	c2( 0 ),
	c3( 0 ),
	Filt(0),
	Peak(0),
	Universal( 0 ) ;

once
	begin
	if BandEdge <= 0 then
		RaiseRunTimeError( "BandEdge must be > zero" ) ;
	end ;

WhiteNoise = ( Close - Close[2] ) / 2 ;

// SuperSmoother Filter
a1 = ExpValue( -1.414 * 3.14159 / BandEdge ) ;
b1 = 2 * a1 * Cosine( 1.414 * 180 / BandEdge ) ;
c2 = b1 ;
c3 = -a1 * a1 ;
c1 = 1 - c2 - c3 ;
Filt = c1 * ( WhiteNoise + WhiteNoise [1] ) / 2 + 
c2 * Filt[1] + c3 * Filt[2] ;
If Currentbar = 1 then 
	Filt = 0 ;
If Currentbar = 2 then 
	Filt = c1 * 0 * ( Close + Close[1] ) / 2 + c2 * Filt[1] ;
If Currentbar = 3 then 
	Filt = c1 * 0 * ( Close + Close[1] ) / 2 + c2 * Filt[1] +
c3 * Filt[2] ;

// Automatic Gain Control (AGC)
Peak = .991 * Peak[1] ;
If Currentbar = 1 then 
	Peak = .0000001 ;
If AbsValue( Filt ) > Peak then 
	Peak = AbsValue( Filt ) ;
If Peak <> 0 then 
	Universal = Filt / Peak ;

if Universal crosses over 0 then
	Buy next bar at Market ;

if Universal crosses under 0 then
	SellShort next bar at Market ;

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
REcommedations for programming help
Sierra Chart
Better Renko Gaps
The Elite Circle
MC PL editor upgrade
MultiCharts
How to apply profiles
Traders Hideout
 
  #2 (permalink)
 
trendwaves's Avatar
 trendwaves 
Florida
Legendary Market Wizard
 
Experience: Advanced
Platform: NinjaTrader 8
Trading: ES, NQ, CL
Posts: 703 since Dec 2012
Thanks Given: 2,898
Thanks Received: 2,525

"<>" is a logical operator for "not equal to"

the if statement in the code is protecting the calculation from a divide by zero error.

so what it is saying is:

if the dividend Peak is not equal to zero then calculate Universal

You need to use the BarNumber() function call to replicate the Currentbar = 1 conditional

This is needed because Peak is initialized to zero, and for the first bar the Peak Calculation
will set Peak equal to zero causing the divide by zero fault in the calculation of Universal.


def Peak = 0.0 ;

Peak = .991 * Peak[1] ;

If BarNumber() == 1 then Peak = 0.0000001 ;

If Peak <> 0 then Universal = Filt / Peak ;

Be Patient and Trade Smart
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #3 (permalink)
nglpx1
viterbo
 
Posts: 1 since Jan 2017
Thanks Given: 0
Thanks Received: 0


Please, someone may explain to me this expression?

Peak = .991 * Peak[1] ;

Peak is not defined before, so how can the term Peak[1] be evaluated?

Thanks.

Reply With Quote
  #4 (permalink)
punchy123
new york city
 
Posts: 1 since Jan 2017
Thanks Given: 0
Thanks Received: 0

I am working through Elher's stuff right now on Think or Swim platform and I had to figure it out earlier today

Good news is that TD has already coded it for and article in traders.com and here is how they did it.



def peak = if IsNaN(filter) then peak[1] * 0.991 else Max(AbsValue(filter), peak[1] * 0.991);



here is the full code and credit to them.

#
# TD Ameritrade IP Company, Inc. (c) 2015-2016
#

declare lower;

input cutoffLength = 20;

def whiteNoise = (close - close[2]) / 2;
def filter = reference EhlersSuperSmootherFilter(price = whiteNoise, "cutoff length" = cutoffLength);
def peak = if IsNaN(filter) then peak[1] * 0.991 else Max(AbsValue(filter), peak[1] * 0.991);

plot UniversalOsc = filter / peak;
plot ZeroLine = 0;

UniversalOsc.SetDefaultColor(GetColor(1));
ZeroLine.SetDefaultColor(GetColor(7));

Reply With Quote




Last Updated on January 30, 2017


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts