MESA Adaptive MA (MAMA/FAMA)¶
Indicators · Moving Averages
Ehlers MESA Adaptive MA — Hilbert-transform adaptive average + FAMA follower.
MAMA — John Ehlers's MESA Adaptive Moving Average — is an average that re-tunes its own speed to the market's dominant cycle instead of a fixed period. It speeds up sharply when the trend turns and slows right down when price drifts, giving a fast-reacting trend line with very little of the lag that dooms ordinary averages at reversals. It ships with its slower twin, FAMA (the Following Adaptive MA), and the MAMA/FAMA crossover is the classic trade signal.
How it works¶
This is a faithful port of Ehlers's published algorithm. A Hilbert-transform "homodyne discriminator" measures the dominant cycle period bar by bar, and the smoothing factor alpha is driven by how fast the cycle's phase is changing:
alpha = FastLimit / (rate of phase change) # clamped between the two limits
MAMA = alpha·price + (1 − alpha)·MAMA[1]
FAMA = 0.5·alpha·MAMA + (1 − 0.5·alpha)·FAMA[1]
When phase rotates quickly (a turn) alpha jumps toward Fast limit (default 0.5) and MAMA accelerates; when phase barely moves (a drift) it falls toward Slow limit (default 0.05) and MAMA glides. FAMA follows at half the alpha, so it trails MAMA and the two cross cleanly at trend changes. Source defaults to hl2 (Ehlers's choice); both lines plot on the price pane in their own colours, with Bull X / Bear X signals on the crosses. The Hilbert filters need a few bars of history, so the opening bars are seeded to price.
When to use it¶
MAMA/FAMA is a trend-following engine: long while MAMA is above FAMA, short while it's below, with the crossovers as entries and exits. Because the average adapts to the cycle rather than a fixed window, it tends to flip earlier than a fixed-MA crossover at genuine turns while staying glued together through drift (cutting some chop). Use it as the trend core of a system, a bias filter for other entries, or a trailing reference. It's at its best in markets with a reasonably persistent cyclic character; in pure random chop the adaptive machinery has less to lock onto.
Example¶
A complete adaptive trend system: wire bars into MAMA, take Bull X straight into a Tester and Bear X into the exit/short, then Tester. Optionally gate entries to a higher-timeframe regime with ADX / DMI so you only act on crosses while a trend is present. Compare its turns against a fixed EMA crossover to see the earlier flips.
Tips & gotchas¶
- Two limits set the range of speeds. Fast limit caps how quick it can get at turns; Slow limit sets the floor during drift. The defaults (0.5 / 0.05) are Ehlers's.
- The MAMA/FAMA cross is the signal — that's what the Bull X / Bear X outputs give you, no extra wiring needed.
- Source is
hl2by default (Ehlers's recommendation); switching toclosechanges the feel. - Loves cycles, dislikes pure noise — in structureless chop the cycle measurement wanders. Pair with a regime filter.
- The most complex indicator here — if an exported MT5/Pine copy matters, verify it on the platform before trusting it live.
Related blocks¶
Inputs¶
| Socket | Type | What to wire in |
|---|---|---|
| Source | bars / series |
Price bars or any indicator series |
Outputs¶
| Output | Type | Plots as | Description |
|---|---|---|---|
| MAMA | series |
Line | MESA Adaptive Moving Average |
| FAMA | series |
Line | Following Adaptive Moving Average |
| Bull X | signal |
Signal arrows | MAMA crosses above FAMA |
| Bear X | signal |
Signal arrows | MAMA crosses below FAMA |
Parameters¶
| Parameter | Type | Default | What it does |
|---|---|---|---|
| Fast limit | number · 0.01–1.0 | 0.5 |
|
| Slow limit | number · 0.01–1.0 | 0.05 |
|
| Source | choice (close, open, high, low, hl2, hlc3, ohlc4) |
hl2 |
|
| MAMA color | colour | #29b6f6 |
|
| FAMA color | colour | #ef5350 |
Reference auto-generated from the block catalog · category Indicators.