John Ehler's indicators

Here you can post and download custom indicators. PLEASE: Do not start topics unless you are posting your own indicator, they will be moved to appropriate section even if you do.

Moderator: admin

John Ehler's indicators

Postby Alexander.Gettinger » Fri Jun 04, 2010 2:03 am

Original researches by John F. Ehlers, described in "Cybernetic Analysis for Stocks and Futures" (2004) ISBN: 0-471-46307-8

Center of Gravity I see also here: viewtopic.php?f=17&t=366&p=605&hilit=Ehler#p605

Ehlers_Indicators.png


Center of Gravity indicator:
Code: Select all
function Init()
    indicator:name("Ehlers CG Oscillator");
    indicator:description("Ehlers CG Oscillator");
    indicator:requiredSource(core.Bar);
    indicator:type(core.Oscillator);
   
    indicator.parameters:addInteger("Length", "Length", "", 10);

    indicator.parameters:addColor("clr_buff1", "Color of Buff1", "Color of Buff1", core.rgb(0, 255, 0));
    indicator.parameters:addColor("clr_buff2", "Color of Buff2", "Color of Buff2", core.rgb(0, 128, 0));
end

local first;
local source = nil;
local Length;
local Price;
local Buff1=nil;
local Buff2=nil;

function Prepare()
    source = instance.source;
    Length=instance.parameters.Length;
    Price = instance:addInternalStream(0, 0);
    first = source:first()+2;
    local name = profile:id() .. "(" .. source:name() .. ", " .. instance.parameters.Length .. ")";
    instance:name(name);
    Buff1 = instance:addStream("Buff1", core.Line, name .. ".Buff1", "Buff1", instance.parameters.clr_buff1, first);
    Buff2 = instance:addStream("Buff2", core.Line, name .. ".Buff2", "Buff2", instance.parameters.clr_buff2, first);
    Buff1:addLevel(0);
end

function Update(period, mode)
    if (period>first+Length) then
     local Num=0.;
     local Demon=0.;
     Price[period]=(source.high[period]+source.low[period])/2.;
     for i=0,Length-1,1 do
      Num=Num+(i+1)*Price[period-i];
      Demon=Demon+Price[period-i];
     end
     if Demon~=0. then
      Buff1[period]=-Num/Demon+(Length+1.)/2.;
     else
      Buff1[period]=0.;
     end
     Buff2[period]=Buff1[period-1];
    end
end


Cyber cycle indicator:
Code: Select all
function Init()
    indicator:name("Ehlers Cyber Cycle");
    indicator:description("Ehlers Cyber Cycle");
    indicator:requiredSource(core.Bar);
    indicator:type(core.Oscillator);
   
    indicator.parameters:addDouble("Alpha", "Alpha", "", 0.07);

    indicator.parameters:addColor("clr_buff1", "Color of Buff1", "Color of Buff1", core.rgb(0, 255, 0));
    indicator.parameters:addColor("clr_buff2", "Color of Buff2", "Color of Buff2", core.rgb(0, 128, 0));
end

local first;
local source = nil;
local Alpha;
local Price;
local Smooth;
local Buff1=nil;
local Buff2=nil;

function Prepare()
    source = instance.source;
    Alpha=instance.parameters.Alpha;
    Price = instance:addInternalStream(0, 0);
    Smooth = instance:addInternalStream(0, 0);
    first = source:first()+2;
    local name = profile:id() .. "(" .. source:name() .. ", " .. instance.parameters.Alpha .. ")";
    instance:name(name);
    Buff1 = instance:addStream("Buff1", core.Line, name .. ".Buff1", "Buff1", instance.parameters.clr_buff1, first);
    Buff2 = instance:addStream("Buff2", core.Line, name .. ".Buff2", "Buff2", instance.parameters.clr_buff2, first);
    Buff1:addLevel(0);
end

function Update(period, mode)
    Price[period]=(source.high[period]+source.low[period])/2.;
    if (period>first+4) then
     Smooth[period]=(Price[period]+2.*Price[period-1]+2.*Price[period-2]+Price[period-3])/6.;
     if period<first+8 then
      Buff1[period]=(Price[period]-2.*Price[period-1]+Price[period-2])/4.;
     else
      Buff1[period]=(1.-0.5*Alpha)*(1.-0.5*Alpha)*(Smooth[period]-2.*Smooth[period-1]+Smooth[period-2])+2.*(1.-Alpha)*Buff1[period-1]-(1.-Alpha)*(1.-Alpha)*Buff1[period-2];
     end
     Buff2[period]=Buff1[period-1];
   
    end
end
Attachments
Ehlers_CG.lua
(1.57 KiB) Downloaded 1159 times
Ehlers_Cyber_Cycle.lua
(1.74 KiB) Downloaded 1024 times
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3238
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: John Ehler's indicators

Postby Alexander.Gettinger » Fri Jun 04, 2010 2:05 am

TwoPole smoothes oscillator:
Code: Select all
function Init()
    indicator:name("Ehlers TwoPole smoothes oscillator");
    indicator:description("Ehlers TwoPole smoothes oscillator");
    indicator:requiredSource(core.Bar);
    indicator:type(core.Oscillator);
   
    indicator.parameters:addInteger("CuttOff", "CuttOff", "", 15);
    indicator.parameters:addDouble("alpha", "alpha", "", 0.15);
    indicator.parameters:addInteger("shift", "shift", "", 0);

    indicator.parameters:addColor("clr_Line", "Color of Line", "Color of Line", core.rgb(0, 255, 0));
    indicator.parameters:addColor("clr_buff1", "Color of Buff1", "Color of Buff1", core.rgb(255, 0, 0));
    indicator.parameters:addColor("clr_buff2", "Color of Buff2", "Color of Buff2", core.rgb(0, 0, 255));
end

local first;
local source = nil;
local CuttOff;
local alpha;
local shift;
local Buff1=nil;
local Buff2=nil;
local BuffLine=nil;
local Ind;

function Prepare()
    source = instance.source;
    CuttOff=instance.parameters.CuttOff;
    alpha=instance.parameters.alpha;
    shift=instance.parameters.shift;
    Ind = core.indicators:create("EHLERS_TWOPOLE_SMOOTHED_FILTER", source, CuttOff);
    first = Ind.DATA:first()+2;
    local name = profile:id() .. "(" .. source:name() .. ", " .. instance.parameters.CuttOff .. ", " .. instance.parameters.alpha .. ", " .. instance.parameters.shift .. ")";
    instance:name(name);
    Buff1 = instance:addStream("Buff1", core.Bar, name .. ".Buff1", "Buff1", instance.parameters.clr_buff1, first);
    Buff2 = instance:addStream("Buff2", core.Bar, name .. ".Buff2", "Buff2", instance.parameters.clr_buff2, first);
    BuffLine = instance:addStream("BuffLine", core.Line, name .. ".BuffLine", "BuffLine", instance.parameters.clr_Line, first);
    BuffLine:addLevel(0);
end

function Update(period, mode)
    if (period>first) then
     Ind:update(mode);
     local Val=Ind.DATA[period]-Ind.DATA[period-1];
     local Val1=Ind.DATA[period-1]-Ind.DATA[period-2];
     local Val2=Ind.DATA[period-2]-Ind.DATA[period-3];
     BuffLine[period]=(alpha-(alpha*alpha/4.))*Val+(alpha*alpha/2.)*Val1-(alpha-3.*alpha*alpha/4.)*Val2+2.*(1-alpha)*BuffLine[period-1]-(1-alpha)*(1-alpha)*BuffLine[period-2];
     if BuffLine[period]<BuffLine[period-1] then
      Buff1[period]=BuffLine[period];
      Buff2[period]=nil;
     else
      Buff1[period]=nil;
      Buff2[period]=BuffLine[period];
     end
     
    end
end


TwoPole smoothes filter:
Code: Select all
function Init()
    indicator:name("Ehlers TwoPole smoothes filter");
    indicator:description("Ehlers TwoPole smoothes filter");
    indicator:requiredSource(core.Bar);
    indicator:type(core.Indicator);
   
    indicator.parameters:addInteger("CuttOffPeriod", "CuttOffPeriod", "", 15);

    indicator.parameters:addColor("clr_Line", "Color of Line", "Color of Line", core.rgb(255, 0, 0));
end

local first;
local source = nil;
local CuttOffPeriod;
local Price;
local BuffLine=nil;
local a1;
local b1;
local coeff1, coeff2, coeff3;

function Prepare()
    source = instance.source;
    CuttOffPeriod=instance.parameters.CuttOffPeriod;
    Price = instance:addInternalStream(0, 0);
    first = source:first()+2;
    local name = profile:id() .. "(" .. source:name() .. ", " .. instance.parameters.CuttOffPeriod .. ")";
    instance:name(name);
    BuffLine = instance:addStream("BuffLine", core.Line, name .. ".BuffLine", "BuffLine", instance.parameters.clr_Line, first);
    a1=math.exp(-math.sqrt(2.)*math.pi/CuttOffPeriod);
    b1=2.*a1*math.cos(math.pi*math.sqrt(2.)/CuttOffPeriod);
    coeff2=b1;
    coeff3=-a1*a1;
    coeff1=1.-coeff2-coeff3;
end

function Update(period, mode)
    Price[period]=(source.high[period]+source.low[period])/2.;
    if (period>first) then
     if period>first+4 then
      BuffLine[period]=coeff1*Price[period]+coeff2*BuffLine[period-1]+coeff3*BuffLine[period-2];
     else
      BuffLine[period]=Price[period];
     end
    end
end
Attachments
Ehlers_TwoPole_Smoothed_Filter.lua
(1.49 KiB) Downloaded 932 times
Ehlers_TwoPole_Smoothed_Oscillator.lua
(2.38 KiB) Downloaded 956 times
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3238
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: John Ehler's indicators

Postby RJH501 » Mon Aug 22, 2011 3:56 am

Hi Alexander,

Would you please add line style and line width to your Ehlers Two Pole indicator when you have time.

Thank you,

Richard
RJH501
 
Posts: 84
Joined: Mon May 30, 2011 8:38 pm

Re: John Ehler's indicators

Postby Apprentice » Mon Aug 22, 2011 12:59 pm

Request is added to our database.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 18973
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: John Ehler's indicators

Postby Alexander.Gettinger » Mon Sep 05, 2011 11:35 am

In the indicators added line style and line width.

Download:
Ehlers_TwoPole_Smoothed_Oscillator.lua
(2.74 KiB) Downloaded 717 times

Ehlers_CG.lua
(2.04 KiB) Downloaded 703 times

Ehlers_Cyber_Cycle.lua
(2.21 KiB) Downloaded 699 times

Ehlers_TwoPole_Smoothed_Filter.lua
(1.85 KiB) Downloaded 680 times
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3238
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: John Ehler's indicators

Postby StefPasc » Mon Sep 23, 2013 6:52 am

Alexander.Gettinger wrote:In the indicators added line style and line width.

Download:
Ehlers_TwoPole_Smoothed_Oscillator.lua

Ehlers_CG.lua

Ehlers_Cyber_Cycle.lua

Ehlers_TwoPole_Smoothed_Filter.lua


Recently I am testing Ehlers Leading Indicator found from
http://fxcodebase.com/code/viewtopic.php?f=17&t=27612&p=48291&hilit=Ehlers+Leading+Indicator#p48291
I have noticed that ELI can be applied not only to the price data but also to another indicator.
Would this be possible also for the above 4 Ehlers indicators ?
Current version of the above 4 indicators does not allow us to apply them on other indicators but only on price data.
Thank you in advance
StefPasc
 
Posts: 42
Joined: Fri Feb 01, 2013 5:53 am
Location: Athens, Greece

Re: John Ehler's indicators

Postby Apprentice » Mon Sep 23, 2013 7:23 am

Possibly, if you do not mind a small change in the original algorithm.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 18973
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: John Ehler's indicators

Postby StefPasc » Mon Sep 23, 2013 7:58 am

Apprentice wrote:Possibly, if you do not mind a small change in the original algorithm.


Dear Apprentice thank you for your reply.
I am not familiar with programming.
Is it possible if you have some time to do this small change ?
Thank you again
StefPasc
 
Posts: 42
Joined: Fri Feb 01, 2013 5:53 am
Location: Athens, Greece

John Ehler's indicators (Tick based versions)

Postby Apprentice » Mon Sep 23, 2013 11:31 am

Tick Ehlers_CG.png

Try this Tick based versions.
Tick Ehlers_CG.lua
(2.28 KiB) Downloaded 413 times

Tick Ehlers_Cyber_Cycle.lua
(2.47 KiB) Downloaded 408 times

Tick Ehlers_TwoPole_Smoothed_Filter.lua
(1.83 KiB) Downloaded 441 times

Tick Ehlers_TwoPole_Smoothed_Oscillator.lua
(2.49 KiB) Downloaded 447 times


Tick Ehlers TwoPole smoothes filter with Alert.lua
(8.54 KiB) Downloaded 258 times


This indicator version will provides Audio / Email Alerts on Price/Tick Ehlers TwoPole smoothes filter cross.

Compatibility issue fixed.
_Alert Helper is not longer needed.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 18973
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: John Ehler's indicators

Postby StefPasc » Wed Sep 25, 2013 2:10 am

thank you Apprentice !
they work fine.. :)
StefPasc
 
Posts: 42
Joined: Fri Feb 01, 2013 5:53 am
Location: Athens, Greece

Next

Return to Custom Indicators

Who is online

Users browsing this forum: Apprentice and 13 guests