OPEN-SOURCE SCRIPT
Perfect Trend EMAs (9-21-50-100)

This indicator provides a clear, color-coded visual representation of trend strength based on the alignment of four Exponential Moving Averages (EMAs). It is designed to help traders identify "Perfect Trend" setups, where momentum is fully aligned across multiple timeframes, and filter out choppy or ranging markets.
How it Works (The Logic) The indicator plots four distinct EMAs (default lengths: 9, 21, 50, and 100). Instead of simply looking for crossovers, this script analyzes the hierarchical stacking of these averages to determine the market state.
The color coding follows these specific rules:
🟢 Bullish Alignment (Green): This occurs only when there is a "Perfect Bullish" stack.
Logic: EMA 9 > EMA 21 > EMA 50 > EMA 100
Interpretation: Short-term momentum is stronger than long-term momentum, indicating a strong uptrend.
🔴 Bearish Alignment (Red): This occurs only when there is a "Perfect Bearish" stack.
Logic: EMA 9 < EMA 21 < EMA 50 < EMA 100
Interpretation: Short-term momentum is weaker than long-term momentum, indicating a strong downtrend.
⚪ Consolidation / Transition (Gray):
Logic: Any other combination.
Interpretation: The moving averages are intertwined or not perfectly aligned. This usually signals a ranging market, a consolidation phase, or the early stages of a trend reversal before the alignment is confirmed.
Features
Dynamic Coloring: All EMA lines change color simultaneously to provide an instant visual signal of the market state.
Visual Fill: A soft background fill is applied between the fastest (9) and slowest (100) EMA to create a "Trend Cloud," making it easier to spot the expansion and contraction of the trend.
Customization: Users can adjust the lengths of all four EMAs in the settings menu to fit different trading styles (e.g., changing to 20/50/100/200).
How to Use
Trend Following: Traders can look for the lines to turn Green or Red to confirm a trend entry.
Filtering Noise: The Gray zones serve as a filter. If the lines are Gray, the trend is not fully established, suggesting caution or a "wait and see" approach.
Exits: A change from Green/Red back to Gray can act as an early warning sign that the trend momentum is fading.
How it Works (The Logic) The indicator plots four distinct EMAs (default lengths: 9, 21, 50, and 100). Instead of simply looking for crossovers, this script analyzes the hierarchical stacking of these averages to determine the market state.
The color coding follows these specific rules:
🟢 Bullish Alignment (Green): This occurs only when there is a "Perfect Bullish" stack.
Logic: EMA 9 > EMA 21 > EMA 50 > EMA 100
Interpretation: Short-term momentum is stronger than long-term momentum, indicating a strong uptrend.
🔴 Bearish Alignment (Red): This occurs only when there is a "Perfect Bearish" stack.
Logic: EMA 9 < EMA 21 < EMA 50 < EMA 100
Interpretation: Short-term momentum is weaker than long-term momentum, indicating a strong downtrend.
⚪ Consolidation / Transition (Gray):
Logic: Any other combination.
Interpretation: The moving averages are intertwined or not perfectly aligned. This usually signals a ranging market, a consolidation phase, or the early stages of a trend reversal before the alignment is confirmed.
Features
Dynamic Coloring: All EMA lines change color simultaneously to provide an instant visual signal of the market state.
Visual Fill: A soft background fill is applied between the fastest (9) and slowest (100) EMA to create a "Trend Cloud," making it easier to spot the expansion and contraction of the trend.
Customization: Users can adjust the lengths of all four EMAs in the settings menu to fit different trading styles (e.g., changing to 20/50/100/200).
How to Use
Trend Following: Traders can look for the lines to turn Green or Red to confirm a trend entry.
Filtering Noise: The Gray zones serve as a filter. If the lines are Gray, the trend is not fully established, suggesting caution or a "wait and see" approach.
Exits: A change from Green/Red back to Gray can act as an early warning sign that the trend momentum is fading.
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.