OPEN-SOURCE SCRIPT
MA Phase Visualizer

🔹 Logic
This indicator classifies market conditions into six phases based on the relative ordering (rank structure) of three moving averages: Short, Mid, and Long.
All possible permutations of these three moving averages are mapped into background colors, allowing the current structural state of the market to be visualized in real time directly on the chart.
🔹 Phase Definitions
Phases are defined by the relative positioning of the moving averages (Short: S, Mid: M, Long: L):
Phase 1 (Red): S > M > L
Phase 2 (Orange): M > S > L
Phase 3 (Yellow): M > L > S
Phase 4 (Green): L > M > S
Phase 5 (Blue): L > S > M
Phase 6 (Purple): S > L > M
💻 Key Features
1. MA Options
Supports five types of moving averages: SMA, EMA, RMA, WMA, and VWMA, allowing flexible adaptation to different trading styles.
2. Mapping
Each phase is mapped to a distinct background color, enabling intuitive identification of the current market structure.
3. Structural Persistence Tracking
Allows users to visually assess how long a given structural arrangement persists over time.
4. Visual Optimization
Adjustable background transparency (bgAlpha) for improved readability and integration with other chart elements.
💡 Interpretation Guide
1. Trending Market
When Phase 1 (uptrend) or Phase 4 (downtrend) persists over an extended period,
the market can be interpreted as being in a structurally stable trending condition.
2. Structural Transitions
Transitions from Phase 1 or 4 into Phase 2 or 5 represent temporary structural shifts.
Monitoring whether the structure returns to the original phase or progresses into a different phase provides insight into trend continuation or breakdown.
3. Ranging Market (Sideways Condition)
When Phase 1 and 4 appear briefly while Phases 2, 3, 5, and 6 alternate frequently over short intervals, the moving averages are converging, indicating a loss of directional structure and a ranging (sideways) market.
⚠️ Notes
This indicator is designed to visualize market structure through moving average ordering.
It classifies the current market state into one of six structural phases based on the relative position of the Short, Mid, and Long moving averages.
The indicator is intended to support market condition analysis and structural interpretation.
For clarity, the three moving averages used in phase classification are displayed on the chart.
This indicator classifies market conditions into six phases based on the relative ordering (rank structure) of three moving averages: Short, Mid, and Long.
All possible permutations of these three moving averages are mapped into background colors, allowing the current structural state of the market to be visualized in real time directly on the chart.
🔹 Phase Definitions
Phases are defined by the relative positioning of the moving averages (Short: S, Mid: M, Long: L):
Phase 1 (Red): S > M > L
Phase 2 (Orange): M > S > L
Phase 3 (Yellow): M > L > S
Phase 4 (Green): L > M > S
Phase 5 (Blue): L > S > M
Phase 6 (Purple): S > L > M
💻 Key Features
1. MA Options
Supports five types of moving averages: SMA, EMA, RMA, WMA, and VWMA, allowing flexible adaptation to different trading styles.
2. Mapping
Each phase is mapped to a distinct background color, enabling intuitive identification of the current market structure.
3. Structural Persistence Tracking
Allows users to visually assess how long a given structural arrangement persists over time.
4. Visual Optimization
Adjustable background transparency (bgAlpha) for improved readability and integration with other chart elements.
💡 Interpretation Guide
1. Trending Market
When Phase 1 (uptrend) or Phase 4 (downtrend) persists over an extended period,
the market can be interpreted as being in a structurally stable trending condition.
2. Structural Transitions
Transitions from Phase 1 or 4 into Phase 2 or 5 represent temporary structural shifts.
Monitoring whether the structure returns to the original phase or progresses into a different phase provides insight into trend continuation or breakdown.
3. Ranging Market (Sideways Condition)
When Phase 1 and 4 appear briefly while Phases 2, 3, 5, and 6 alternate frequently over short intervals, the moving averages are converging, indicating a loss of directional structure and a ranging (sideways) market.
⚠️ Notes
This indicator is designed to visualize market structure through moving average ordering.
It classifies the current market state into one of six structural phases based on the relative position of the Short, Mid, and Long moving averages.
The indicator is intended to support market condition analysis and structural interpretation.
For clarity, the three moving averages used in phase classification are displayed on the chart.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.