Guppy's Multiple Moving Average and Convergence/Divergence

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

Guppy's Multiple Moving Average and Convergence/Divergence

Postby Nikolay.Gekht » Fri Feb 26, 2010 7:49 pm

GMMA (Guppy's Multiple Moving Average) is 12 EMA lines:

1) Short (Fast) Group:
EMA(3), EMA(5), EMA(8), EMA(10), EMA(12), EMA(15)

1) Long (Slow) Group:
EMA(30), EMA(35), EMA(40), EMA(45), EMA(50), EMA(60)

GMMACD (Guppy's Multiple Moving Average Convergence/Divergence) is calculated as:
f = SUM(Fast EMA's)
s = SUM(Slow EMA's)
GMMACD = (s - f) / s * 100


gmma.png


GMMA.lua
Code: Select all
function Init()
    indicator:name("Guppy's Multiple Moving Average");
    indicator:requiredSource(core.Tick);
    indicator:type(core.Indicator);

    indicator.parameters:addColor("S_COLOR", "Color for the short EMA group", "", core.rgb(0, 0, 255));
    indicator.parameters:addColor("L_COLOR", "Color for the long EMA group", "", core.rgb(255, 0, 0));
end

local source = nil;
local EMAs = {};    -- an array of outputs

function CreateEMA(index, N, color, name)
    local label;
    -- line label
    label = "EMA" .. N;
    -- create the line
    EMAs[index] = instance:addStream(label, core.Line, name .. label, label,
                                     color, source:first() + N - 1);
end

function Prepare()
    source = instance.source;
    local name;

    -- set the indicator name (use the short name of our indicator: GMMA)
    name = profile:id() .. "(" .. source:name() .. ")";
    instance:name(name);

    CreateEMA(0, 3, instance.parameters.S_COLOR, name);
    CreateEMA(1, 5, instance.parameters.S_COLOR, name);
    CreateEMA(2, 8, instance.parameters.S_COLOR, name);
    CreateEMA(3, 10, instance.parameters.S_COLOR, name);
    CreateEMA(4, 12, instance.parameters.S_COLOR, name);
    CreateEMA(5, 15, instance.parameters.S_COLOR, name);

    CreateEMA(6, 30, instance.parameters.L_COLOR, name);
    CreateEMA(7, 35, instance.parameters.L_COLOR, name);
    CreateEMA(8, 40, instance.parameters.L_COLOR, name);
    CreateEMA(9, 45, instance.parameters.L_COLOR, name);
    CreateEMA(10, 50, instance.parameters.L_COLOR, name);
    CreateEMA(11, 60, instance.parameters.L_COLOR, name);
end

function CalcEMA(index, N, period)
    local first;

    first = source:first() + N - 1;
    if period < first then
       return ;
    elseif period == first then
       -- range: period - N + 1, period - N + 2, ..., period
       local range = core.rangeTo(period, N);
       EMAs[index][period] = core.avg(source, range);
    else
       local k;
       k = 2.0 / (N + 1.0);
       -- EMA - PRICE * K - PREV EMA * (1 - K)
       EMAs[index][period] = source[period] * k + EMAs[index][period - 1] * (1 - k);
    end
end

function Update(period)
    CalcEMA(0, 3, period);
    CalcEMA(1, 5, period);
    CalcEMA(2, 8, period);
    CalcEMA(3, 10, period);
    CalcEMA(4, 12, period);
    CalcEMA(5, 15, period);

    CalcEMA(6, 30, period);
    CalcEMA(7, 35, period);
    CalcEMA(8, 40, period);
    CalcEMA(9, 45, period);
    CalcEMA(10, 50, period);
    CalcEMA(11, 60, period);
end


GMMACD.lua
Code: Select all
function Init()
    indicator:name("Guppy's Multiple Moving Average Convergence/Divergence");
    indicator:requiredSource(core.Tick);
    indicator:type(core.Oscillator);

    indicator.parameters:addColor("COLOR", "Indicator's Color", "", core.rgb(255, 0, 0));
end

local source = nil;
local GMMA = nil;
local out = nil;
local first = nil;

function Prepare()
    source = instance.source;
    local name;
    -- set the indicator name (use the short name of our indicator: GMMA)
    name = profile:id() .. "(" .. source:name() .. ")";
    instance:name(name);
    GMMA = core.indicators:create("GMMA", source);
    first = GMMA:getStream(11):first();
    out = instance:addStream("H", core.Bar, name .. ".H", "H", instance.parameters.COLOR, first);
    out:addLevel(0);
end

function Update(period, mode)
    GMMA:update(mode);

    if (period >= first) then
        local f, s;
        f = GMMA:getStream(0)[period] + GMMA:getStream(1)[period] + GMMA:getStream(2)[period] +
            GMMA:getStream(3)[period] + GMMA:getStream(4)[period] + GMMA:getStream(5)[period];
        s = GMMA:getStream(6)[period] + GMMA:getStream(7)[period] + GMMA:getStream(9)[period] +
            GMMA:getStream(9)[period] + GMMA:getStream(10)[period] + GMMA:getStream(11)[period];
        out[period] = (f - s) / s * 100;
    end
end


Download:
GMMA.lua
(4 KiB) Downloaded 7224 times

GMMACD.lua
(1.32 KiB) Downloaded 5847 times

Note: you must have GMMA.lua installed in order to use GMMACD.lua


CGMMA.png

Version that allows you to define EMA periods.
CGMMA.lua
(5.25 KiB) Downloaded 2715 times

CGMMACD.lua
(2.19 KiB) Downloaded 2390 times

Note: you must have CGMMA.lua installed in order to use CGMMACD.lua

EURUSD D1 (07-04-2016 0010).png

GMMACD Overlay.lua
(3.87 KiB) Downloaded 311 times
Nikolay.Gekht
FXCodeBase: Base Builder
 
Posts: 1222
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC

Re: Guppy's Multiple Moving Average and Convergence/Divergence

Postby air2art » Mon Jun 07, 2010 4:38 am

hi any chance for a signal when the oscilaltor crossess above/below the 0 line
Thanks
air2art
 
Posts: 1
Joined: Sun Jun 06, 2010 11:12 pm

Re: Guppy's Multiple Moving Average and Convergence/Divergence

Postby Apprentice » Tue Jun 08, 2010 1:29 pm

User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 17418
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Guppy's Multiple Moving Average and Convergence/Divergence

Postby Jigit Jigit » Tue Aug 31, 2010 2:24 pm

Thanks a lot for this one.
I've just started using GMMA and I already love it.

But I'm also a very unexperienced demo trader so...
Can someone, please, explain it to me how this GMMACD indicator works?

Cheers
Jigit Jigit
 
Posts: 54
Joined: Tue Aug 31, 2010 1:04 pm

Re: Guppy's Multiple Moving Average and Convergence/Divergence

Postby Nikolay.Gekht » Thu Sep 02, 2010 12:10 pm

As said in the first post GMMACD is the indicator which shows relationship between fast and slow moving averages of GMMA indicator. When the indicator is above zero, the sum of fast MA's is above the sum of slow MAs, when it is below zero - the fast MA's are below slow MA's. The using of the "cross zero" signal is similar to use of two MA intersection. When it goes above zero - it indicates the uptrend. When it goes below zero - it indicates the downtrend. Because, like any MA indicator is a bit inertial (i.e. it shows signal with a lag), the trend must be long enough to be successfully detected.
Nikolay.Gekht
FXCodeBase: Base Builder
 
Posts: 1222
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC

Re: Guppy's Multiple Moving Average and Convergence/Divergence

Postby Apprentice » Tue Sep 21, 2010 4:15 pm

GMMA Style Update
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 17418
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Guppy's Multiple Moving Average and Convergence/Divergence

Postby Jigit Jigit » Thu Jan 12, 2012 4:14 am

Great job. Thank you.
Could you possibly add a line following the ends of the bars of the histogram - something like the slow CCI line in Woodies CCI indicator. It would make the indicator even more readable. Its colour could be specified by the user.

Cheers
Jigit Jigit
 
Posts: 54
Joined: Tue Aug 31, 2010 1:04 pm

Re: Guppy's Multiple Moving Average and Convergence/Divergence

Postby Apprentice » Fri Jan 13, 2012 3:48 am

Your request is added to the developmental cue.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 17418
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Guppy's Multiple Moving Average and Convergence/Divergence

Postby jackfx09 » Fri Jan 13, 2012 7:20 am

Nice work!

Simple and effective indicator!

Could we please have the OPTION of changing the time frames for the EMA's used? Example:

2,5,10,17,25,50 for the short (FAST) and
50,100,200,350,500,1000 for the long (SLOW) groups


Thanks!
sjc
jackfx09
 
Posts: 53
Joined: Wed Aug 17, 2011 1:03 pm

Re: Guppy's Multiple Moving Average and Convergence/Divergence

Postby Apprentice » Sun Jan 15, 2012 4:42 am

Your request is added to the developmental cue.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 17418
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Next

Return to Custom Indicators

Who is online

Users browsing this forum: 7000306337 and 9 guests