PROTECTED SOURCE SCRIPT

Adaptive MACD Suite (MAMA / FAMA / KAMA) By Tehreem 2.0

52
Adaptive MACD built without simple moving averages.
Choose your engine: MAMA–FAMA (Ehlers), MAMAx2, FAMAx2, or KAMAx2 (Kaufman Adaptive). The histogram is the classic MACD histogram (MACD − Signal), plotted with rising/falling tint just like the standard indicator—only smarter and fully adaptive.

Why this indicator?

Traditional MACD relies on simple or exponential MAs that lag in fast markets. This tool replaces them with adaptive baselines so your MACD reacts to real-time market dynamics:

MAMA–FAMA (John Ehlers) adapts with instantaneous phase/alpha.

KAMA (Perry Kaufman) adapts using Efficiency Ratio (ER).

MAMAx2 / FAMAx2 let you compare two adaptive lines of the same family (fast vs slow).

Result: faster trend detection, cleaner momentum shifts, and fewer whipsaws across forex, crypto, stocks, indices, gold (XAUUSD), and more.

What it does (at a glance)

MACD Line: difference between selected adaptive fast & slow lines (per mode).

Signal Line: EMA of MACD (length adjustable).

Histogram: MACD − Signal with positive/negative & rising/falling colors for instant read.

Source Option: Use Heiken Ashi close or regular close to fit HA-based systems.

Alerts: Bull/Bear crosses and zero-line shifts (ready to hook into your trade rules).

Modes (pick one)

MAMA_FAMA: Classic Ehlers pair. MACD = MAMA − FAMA. Great all-rounder for momentum + trend confirmation.

MAMAx2: MACD = MAMA(fast) − MAMA(slow). Keeps the Ehlers feel while separating pace.

FAMAx2: MACD = FAMA(fast) − FAMA(slow). A smoother, slightly slower flavor of the Ehlers family.

KAMAx2: MACD = KAMA(fast ER) − KAMA(slow ER). Excellent in choppy assets; adapts to noise.

All engines are coded from scratch (no built-ins), Pine v6, and calibrated to behave like a “real” MACD—just without SMA/EMA as the core trend inputs.

How to use it (practical playbook)

Trend confirmation: Trade in the direction of MACD above/below zero.

Entry timing: Look for MACD crossing Signal in trend direction.

Momentum strength: Expanding histogram indicates acceleration; contracting suggests a pause or pullback.

Divergence spotting: Price vs. MACD divergences remain valid—adaptive baselines can reveal them earlier.

Heiken Ashi workflows: Flip “Use Heiken Ashi Close as Source” on to align with HA entries (e.g., HA green above baseline + MACD > 0).

Suggested starting settings

MAMA_FAMA: fastLimit = 0.50, slowLimit = 0.05, Signal = 9

MAMAx2: M1: 0.60/0.04, M2: 0.30/0.02

FAMAx2: M1: 0.50/0.05, M2: 0.25/0.03

KAMAx2: Fast ER = 10, Slow ER = 30, FastLen = 2, SlowLen = 30, Signal = 9

Tweak signal length a bit higher for very noisy symbols (e.g., some crypto pairs) and a bit lower for smoother indices.

Included alerts (ready to use)

MACD Bull/Bear Cross (MACD ↔ Signal)

MACD > 0 / < 0 (regime shifts)

Optional Histogram Rising/Falling momentum alerts

Who is it for?

Traders who prefer adaptive indicators over fixed-period SMAs/EMAs.

Trend-followers and swing traders needing cleaner momentum confirmation.

Scalpers and intraday traders on volatile instruments (crypto, gold, NASDAQ) who want faster reaction without overfitting.

Tips & best practices

Pair with a baseline (e.g., EMA/MAMA on price) for structure; use Adaptive MACD for timing.

On higher timeframes, MAMA_FAMA often gives very clean signals.

In range markets, KAMAx2 typically filters noise better.

For 1:3 RR systems, use MACD for confirmation, not as the sole trigger.

Notes & disclaimer

Built for Pine v6.

This is a tool, not financial advice. Always validate on your market/timeframe and use proper risk management.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.