## MAMA

The MAMA or Mother Of Adaptive Moving Averages was authored by John Ehlers. The MAMA uses the current price, three previous prices, several feedback sequences, a few math functions and factors, and some more feedback for its final calculation. A signal line, called the FAMA which is derived from the MAMA, is also given. The user may change the input (midpoint) and the fast and slow factors. This indicator’s definition is further expressed in the condensed code given in the calculation below. ### How To Trade Using MAMA

If the MAMA crosses below the FAMA a sell signal will be generated. Conversely, if the MAMA crosses above the FAMA a buy signal will be given. ### How To Access in MotiveWave

Go to the top menu, choose Study>John Ehlers>MAMA

or go to the top menu, choose Add Study, start typing in this study name until you see it appear in the list, click on the study name, click OK.

Important Disclaimer: The information provided on this page is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security. Please see our Risk Disclosure and Performance Disclaimer Statement.

### Calculation

//input = price, user defined, default is midpoint
//fast = user defined, default is .5
//slow = user defined, default is .05
//prev = previous, index = current bar number

```prevPrice1 = price[index-1];
prevPrice2 = price[index-2];
prevPrice3 = price[index-3];
prevPrd = period[index-1];
smooth = (4 * price + 3 * prevPrice1 + 2 * prevPrice2 + prevPrice3)  / 10;
prevS2 = smooth[index-2];
prevS4 = smooth[index-4];
prevS6 = smooth[index-6];
det = (.0962 * smooth + .5769 * prevS2 - .5769 * prevS4 - .0962 * prevS6) * (.075 * prevPrd + .54);
prevD2 = det[index-2];
prevD3 = det[index-3];
prevD4 = det[index-4];
prevD6 = det[index-6];
q1 = (.0962 * det + .5769 * prevD2 - .5769 * prevD4 - .0962 * prevD6) * (.075 * prevPrd + .54);
i1 = prevD3;
prevQ1x2 = q1[index-2];
prevQ1x4 = q1[index-4];
prevQ1x6 = q1[index-6];
prevI1x2 = i1[index-2];
prevI1x4 = i1[index-4];
prevI1x6 = i1[index-6];
j1 = (.0962 * i1 + .5769 * prevI1x2 - .5769 * prevI1x4 - .0962 * prevI1x6) * (.075 * prevPrd + .54);
jq = (.0962 * q1 + .5769 * prevQ1x2 - .5769 * prevQ1x4 - .0962 * prevQ1x6) * (.075 * prevPrd + .54);
i2 = i1 - jq;
q2 = q1 + j1;
prevI2 = i2[index-1];
prevQ2 = q2[index-1];
i2 = .2*i2 + .8 * prevI2;
q2 = .2*q2 + .8 * prevQ2;
re = i2*prevI2 + q2 * prevQ2;
im = i2*prevQ2 - q2 * prevI2;
prevRe = re[index-1];
prevIm = im[index-1];
re = .2*re + .8 * prevRe;
im = .2*im + .8 * prevIm;
if (im != 0 AND re != 0) period = 360/Math.atan(im/re);
if (period moreThan 1.5 * prevPrd) period = 1.5 * prevPrd;
if (period lessThan .67 * prevPrd) period = .67 * prevPrd;
if (period  50) period = 50;
period = .2 * period + .8 * prevPrd;
prevSprd = sprd[index-1];
sPrd = .33 * period + .67 * prevSprd;
if (i1 != 0) phase = Math.atan(q1/i1);
prevPhase = phase[index-1];
deltaPhase = prevPhase - phase;
if (deltaPhase lessThan 1) deltaPhase = 1;
alpha = fast / deltaPhase;
if (alpha lessThan slow) alpha = slow;
prevMama = mama[index-1];
prevFama = fama[index-1];
Plot1: mama = alpha * price + (1 - alpha) * prevMama;
Plot2: fama = .5 * alpha * mama + (1 - .5 * alpha) * prevFama;
//Signals