## 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.

### Guppy's Multiple Moving Average and Convergence/Divergence

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.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));endlocal source = nil;local EMAs = {};    -- an array of outputsfunction 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);endfunction 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);endfunction 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);    endendfunction 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));endlocal 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);endfunction 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;    endend`

GMMA.lua

GMMACD.lua

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

Version that allows you to define EMA periods.
CGMMA.lua

CGMMACD.lua

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

GMMACD Overlay.lua
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

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

Apprentice
FXCodeBase: Confirmed User

Posts: 17153
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

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

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

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

GMMA Style Update

Apprentice
FXCodeBase: Confirmed User

Posts: 17153
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

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

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

Apprentice
FXCodeBase: Confirmed User

Posts: 17153
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

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

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

Apprentice
FXCodeBase: Confirmed User

Posts: 17153
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Next