MAMA

Modified on 2011/12/31 14:28 by Eugene — Categorized as: Standard Indicators

Syntax

public MAMA(DataSeries source, double FastLimit, double SlowLimit, string description)
public static MAMA Series(DataSeries source, double fastLimit, double slowLimit)

Parameter Description

source DataSeries
fastLimit The maximum alpha value
slowLimit The minimum alpha value

Description

MAMA stands for MESA Adaptive Moving Average. It was developed by John Ehlers of Mesa Software, and presented in the September 2001 issue of Stocks & Commodities magazine. MAMA is an adaptive exponential moving average. The EMA's alpha (α) is related to the phase rate of change (the degree to which the phase of the market cycle changes from bar to bar).

In addition to Price Series, MAMA accepts two additional parameters, FastLimit and SlowLimit. These control the maximum and minimum alpha (α) value that should be applied to the most recent bar of data when calculating MAMA.

You can learn more about the Mesa Adaptive Moving Average at the Mesa Software web site.

Interpretation


Calculation

MAMA = α * Price + ( 1 - α ) * MAMAPrevious

This is a typical exponential moving average calculation. The difference is that the alpha value changes bar by bar, and is based on the following formula:

α = FastLimit / DeltaPhase

DeltaPhase is the rate of change of the Hilbert Transform homodyne discriminator. The alpha value is kept within the range of FastLimit and SlowLimit.

Example

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { DataSeries hMA = MAMA.Series( Close, 0.5, 0.05 ); DataSeries hFA = FAMA.Series( Close, 0.5, 0.05 ); PlotSeries( PricePane, hMA, Color.Red, WealthLab.LineStyle.Solid, 1 ); PlotSeries( PricePane, hFA, Color.Blue, WealthLab.LineStyle.Solid, 1 ); for(int bar = hMA.FirstValidValue; bar < Bars.Count; bar++) { if( CrossOver( bar, hMA, hFA ) ) BuyAtMarket( bar+1 ); else if( CrossOver( bar, hFA, hMA ) ) SellAtMarket( bar+1, LastPosition ); } } } }