indicator · on price · open source

Ehlers MESA Adaptive MA

Deepwick · @deepwickv1Updated 2 Oct 2026▲ 0 users
Running…
Loading chart…

About

Ehlers MESA Adaptive Moving Average (MAMA / FAMA) — the first derivative of the dominant cycle phase. MAMA tracks price, FAMA is the slower confirmation; MAMA > FAMA = trend up.

  • alpha controls the maximum adaptation speed; smaller = more conservative.
  • Best on volatile instruments where standard MAs lag too much.

Source code

//@version=5
indicator("Ehlers MESA Adaptive MA", overlay=true)
alpha = input.float(0.5, "Max alpha", minval=0.05, maxval=0.95, step=0.01)
src = (high + low) / 2
diff = src - src[1]
price = 0.0667 * (diff + 0.5 * (diff[1] - diff[2]) + 0.1667 * (diff[3] - diff[4]))
var float mama = price
var float fama = price
mama := alpha * price + (1 - alpha) * nz(mama[1], price)
fama := 0.5 * alpha * price + (1 - 0.5 * alpha) * nz(fama[1], price)
p_MAMA = plot(mama, "MAMA", color=color.blue, linewidth=2)
p_FAMA = plot(fama, "FAMA", color=color.red, linewidth=2)
alertcondition(ta.crossover(mama, fama), "MAMA above FAMA", "MAMA crossed above FAMA")
alertcondition(ta.crossunder(mama, fama), "MAMA below FAMA", "MAMA crossed below FAMA")

Comments

No comments yet.

Sign in to comment.