OPEN-SOURCE SCRIPT

MAMA/FAMA Adaptive Trend

624
MAMA/FAMA Adaptive Trend

1. Overview

MAMA/FAMA Adaptive Trend is an adaptive moving average indicator based on John Ehlers' MESA Adaptive Moving Average concept.

תמונת-בזק

The indicator plots two adaptive lines:

* MAMA: the faster adaptive moving average
* FAMA: the slower following adaptive moving average

The tool is designed to help traders study adaptive trend state, trend transitions, and filtered MAMA/FAMA cross events directly on the price chart.

This is an indicator, not a strategy. It does not place orders, does not execute trades, and does not produce TradingView Strategy Tester backtest results. Entry and exit markers are visual chart events only and should not be treated as guaranteed trading signals or financial advice.

2. Core Idea

Traditional moving averages use fixed periods. MAMA/FAMA is different because it adapts its smoothing behavior according to the market's measured cycle and phase behavior.

When market phase changes quickly, MAMA can become more responsive.

When market movement is slower or steadier, MAMA can smooth more heavily.

FAMA follows MAMA using a slower adaptive response.

The relationship between MAMA and FAMA is used to define the current adaptive trend state:

* MAMA above FAMA suggests a bullish adaptive state.
* MAMA below FAMA suggests a bearish adaptive state.

3. MAMA and FAMA Lines

MAMA

MAMA is the faster adaptive line. It reacts more quickly to changes in price behavior.

FAMA

FAMA is the following adaptive line. It is slower than MAMA and provides a smoother reference.

MAMA/FAMA Fill

The area between MAMA and FAMA can be filled:

* Green fill suggests a bullish adaptive state.
* Red fill suggests a bearish adaptive state.

This fill is visual context only. It does not guarantee future price direction.

4. Adaptive Trend State

The indicator uses the position of MAMA relative to FAMA to define trend state.

Bullish state

A bullish adaptive state occurs when MAMA is above FAMA.

Bearish state

A bearish adaptive state occurs when MAMA is below FAMA.

The color of the MAMA line and the fill can change according to this state.

5. Entry Filters

The script includes entry filters designed to reduce weak crosses in sideways or noisy markets.

The entry filters are applied only to entry markers.

Exit markers use separate logic and are not blocked by the same entry filters.

Minimum MAMA/FAMA Gap Filter

This filter checks whether the distance between MAMA and FAMA is large enough relative to ATR.

The logic is based on:

MAMA/FAMA gap divided by ATR

If the gap is too small, the cross can be ignored as a weak entry event.

Default settings:

* Gap ATR length: 12
* Minimum gap in ATR: 0.05

MAMA Slope Filter

This filter checks the slope of MAMA.

A bullish entry requires MAMA to be rising.

A bearish entry requires MAMA to be falling.

This can help reduce entry markers during flat or unclear market conditions.

6. Entry Markers

The script can display filtered entry markers.

Bull Entry

A Bull Entry marker appears when MAMA crosses above FAMA and the entry filters pass.

Bear Entry

A Bear Entry marker appears when MAMA crosses below FAMA and the entry filters pass.

Important note

These markers are adaptive trend-state events. They are not guaranteed buy or sell signals.

7. Exit Markers

The script includes separate exit markers.

Exit Long

An Exit Long marker appears when the indicator is in a visual long state and MAMA crosses below FAMA.

This exit is not blocked by the entry filters.

Exit Short

An Exit Short marker appears when the indicator is in a visual short state and MAMA crosses above FAMA.

This exit is not blocked by the entry filters.

Why exit logic is separate

Entry filters can be useful for reducing weak entries, but exits often need to react faster.

For this reason, the script uses filtered logic for entries and raw opposite MAMA/FAMA crosses for exits.

8. Signal Marker Placement

Entry and exit markers are placed using ATR-based distance from candles.

This helps reduce marker overlap with price bars.

Users can adjust:

Signal distance from candles (ATR)

Increasing this value moves markers farther away from candles.

Decreasing this value places markers closer to candles.

9. Display Options

The script includes display settings for:

* Entry markers
* Exit markers
* MAMA/FAMA fill
* Optional background regime

The background regime is OFF by default to keep the chart clean.

10. Alerts

The script includes alert conditions for:

* Bull Entry
* Bear Entry
* Exit Long
* Exit Short

Alerts are notifications only. They do not place trades and do not confirm broker execution.

11. How to Use

A practical workflow:

1. Use the MAMA/FAMA lines to identify the adaptive trend state.

2. Look for green fill when MAMA is above FAMA.

3. Look for red fill when MAMA is below FAMA.

4. Use Bull Entry and Bear Entry markers as filtered adaptive cross events.

5. Use Exit Long and Exit Short markers as visual exit references.

6. Adjust the gap filter if too many or too few entry markers appear.

7. Adjust marker distance if entry or exit markers are too close to candles.

8. Combine the indicator with market structure, volume, support/resistance, and risk management.

9. Suggested Use Cases

MAMA/FAMA Adaptive Trend can be used for:

* Adaptive trend-state analysis
* Moving average trend filtering
* Trend transition study
* Visual trend-following context
* Exit reference based on opposite adaptive crosses
* Cleaner MAMA/FAMA cross visualization

13. Important Limitations

This indicator does not predict future price movement.

It does not guarantee profitable trades.

It is not a trading strategy.

It does not place orders.

It does not produce Strategy Tester results.

MAMA/FAMA crosses can whipsaw in sideways markets.

Adaptive moving averages can still lag during sharp reversals.

Entry and exit markers are visual events only.

A Bull Entry marker is not a guaranteed buy signal.

A Bear Entry marker is not a guaranteed sell signal.

Exit markers are not broker fills.

Users are responsible for their own trading decisions, risk management, and position sizing.

14. Originality and Purpose

MAMA/FAMA Adaptive Trend combines the MESA Adaptive Moving Average concept with cleaner TradingView visualization and practical signal filtering.

The script adds:

* Filtered entry markers
* Separate exit markers
* ATR-based marker spacing
* Optional fill between MAMA and FAMA
* Optional background regime
* Alerts for entry and exit events
* Cleaner chart output without a dashboard/table

The purpose of the indicator is to help traders study adaptive trend behavior in a simple and visually clear way.

15. Educational Disclaimer

This script is for educational and chart-analysis purposes only. It is not financial advice, investment advice, or a recommendation to buy or sell any financial instrument. Users should perform their own analysis and manage risk independently.

כתב ויתור

המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.