OPEN-SOURCE SCRIPT
MAMA - FAMA (Ehlers) [KN]

MAMA - FAMA (Ehlers)
Surprisingly, I couldn't find a proper Pine Script implementation of this classic indicator on TradingView, so here's my version.
This indicator implements John Ehlers' MESA Adaptive Moving Average (MAMA) and Following Adaptive Moving Average (FAMA) from his book "Rocket Science for Traders."
How It Works
Unlike traditional moving averages with fixed periods, MAMA adapts its smoothing based on the market's dominant cycle. It uses the Hilbert Transform to measure the instantaneous phase of price, then adjusts its responsiveness according to how fast that phase is changing.
When price is trending strongly (rapid phase change), MAMA speeds up to follow closely. During consolidation (slow phase change), it slows down to filter noise. FAMA is a further smoothed version of MAMA that serves as a signal line.
Signals
🔵 Bullish: MAMA crosses above FAMA
🟠 Bearish: MAMA crosses below FAMA
The adaptive nature makes this particularly effective at avoiding whipsaws during ranging markets while still catching trends early.
Inputs
- Fast Limit (default 0.5): Maximum alpha, controls fastest response
- Slow Limit (default 0.05): Minimum alpha, controls slowest response
- Source (default hl2): Price input
Credits
Original concept by John F. Ehlers.
Surprisingly, I couldn't find a proper Pine Script implementation of this classic indicator on TradingView, so here's my version.
This indicator implements John Ehlers' MESA Adaptive Moving Average (MAMA) and Following Adaptive Moving Average (FAMA) from his book "Rocket Science for Traders."
How It Works
Unlike traditional moving averages with fixed periods, MAMA adapts its smoothing based on the market's dominant cycle. It uses the Hilbert Transform to measure the instantaneous phase of price, then adjusts its responsiveness according to how fast that phase is changing.
When price is trending strongly (rapid phase change), MAMA speeds up to follow closely. During consolidation (slow phase change), it slows down to filter noise. FAMA is a further smoothed version of MAMA that serves as a signal line.
Signals
🔵 Bullish: MAMA crosses above FAMA
🟠 Bearish: MAMA crosses below FAMA
The adaptive nature makes this particularly effective at avoiding whipsaws during ranging markets while still catching trends early.
Inputs
- Fast Limit (default 0.5): Maximum alpha, controls fastest response
- Slow Limit (default 0.05): Minimum alpha, controls slowest response
- Source (default hl2): Price input
Credits
Original concept by John F. Ehlers.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.