OPEN-SOURCE SCRIPT
Zaktualizowano EMA Cluster Absorption Engine [KNN Engine]

EMA Cluster Absorption Engine [KNN Engine]
1. What the Script Does
The EMA Cluster Absorption Engine is a high-sensitivity momentum and consensus oscillator designed to identify sharp, momentum-driven reversals (often referred to as "V-Bottoms" or "V-Tops"). It moves beyond standard moving averages by evaluating price action across 24 simultaneous Exponential Moving Average (EMA) time-horizons.
Furthermore, it introduces a built-in K-Nearest Neighbors (KNN) Machine Learning Algorithm to calculate the statistical probability of a mean-reversion bounce based on historical market data.
Rather than relying on a single, arbitrary EMA length, this indicator mathematically aggregates 24 distinct momentum cycles to verify if the entire institutional ecosystem is overextended. It visualizes this data through a dynamically scaling histogram, a multi-ribbon fan, and volatility boundaries.
2. The Core Innovation: How it Calculates Everything
Standard moving averages rely on fixed lookback periods (e.g., a 50-EMA), which inherently lag the market and drop relevant historical data. This script is fundamentally original because it abandons fixed lookbacks in favor of Anomaly Anchoring, Expanding EMA Recursion, and Predictive Classification.
Anomaly Anchoring: The engine constantly scans volume for statistical deviations. When it detects a volume spike exceeding a 2.5 Z-Score, it drops a mathematical "Anchor." It tracks the last 24 of these institutional liquidity events simultaneously.
Expanding EMA Recursion: From each of the 24 anchor points, the script begins calculating an independent EMA. Unlike fixed EMAs, these use an "Expanding Alpha" ($\alpha = 2 / (count + 1)$), making them incredibly sensitive to the initial impulse of a new trend while maintaining the memory of the anchor point.
The Consensus Meta-Mean: The script calculates the absolute average of all 24 active EMA lines. This "Meta-EMA" represents the true equilibrium of the market's current momentum. The distance of price from this average is converted into a Z-Score, standardizing the deviation across any asset class.
The K-Nearest Neighbors (KNN) Engine: When the script detects 100% Consensus (e.g., all 24 active EMAs are simultaneously above or below price), it captures the exact numerical fingerprint of the market (EMA Deviation, EMA Velocity, and Price Velocity). The KNN engine calculates the Euclidean Distance between the current fingerprint and the last 300 historical fingerprints. It finds the 5 nearest neighbors (the 5 times history looked mathematically identical) and checks their win/loss results to generate a live probability score.
3. Justifying the Methodology
Why combine 24 expanding EMAs with a KNN machine learning model? Because fast-moving markets frequently outrun standard indicators.
In high-volatility environments, traditional simple moving averages (SMAs) lag too much to catch the absolute bottom or top. EMAs hug price closer, making them the preferred benchmark for momentum algorithms. By anchoring 24 separate EMAs to actual volume anomalies, we verify if the entire market ecosystem—even the most sensitive momentum metrics—agrees on the overextension. By passing that data through a KNN algorithm, we filter out low-quality traps by asking the data: "The last 5 times momentum snapped this aggressively, did price successfully reverse by at least 0.1%?"
4. How to Use the Indicator
Visual Layout:
The Structural Fan (Ribbons): 24 individual EMA lines plotted on a standardized Z-axis. When tightly compressed, momentum is structurally unanimous. When fanned out, momentum is decaying or conflicted.
The Engine Histogram: Visualizes the standardized deviation of price from the Meta-EMA.
Expansion (Bright): Bright Blue or Bright Lime/Red bars indicate that momentum is actively accelerating away from equilibrium.
Contraction (Dark): Dark, highly transparent bars indicate that momentum is decaying or cooling off back toward the zero-line.
Tactical Trade Execution:
Spot the Momentum Purge: Watch the histogram expand into extreme territory (Lime for bullish potential, Red for bearish potential). Because this is an EMA engine, this happens when price moves faster than the institutional momentum "gas" can follow. Do not enter yet.
Wait for the Machine Learning Confirmation: Wait for the background to flash Lime (Bullish) or Red (Bearish) with a printed percentage (e.g., 80%). This means the KNN algorithm has verified that identical historical momentum snaps successfully reversed price.
The Trigger: Wait for the white Signal Line to peak (often printing an Exhaustion ✧ marker) and begin receding back toward the zero-line, ultimately "re-enveloping" the histogram bars. This confirms that the extreme directional friction has officially snapped, signaling a high-probability mean reversion.
1. What the Script Does
The EMA Cluster Absorption Engine is a high-sensitivity momentum and consensus oscillator designed to identify sharp, momentum-driven reversals (often referred to as "V-Bottoms" or "V-Tops"). It moves beyond standard moving averages by evaluating price action across 24 simultaneous Exponential Moving Average (EMA) time-horizons.
Furthermore, it introduces a built-in K-Nearest Neighbors (KNN) Machine Learning Algorithm to calculate the statistical probability of a mean-reversion bounce based on historical market data.
Rather than relying on a single, arbitrary EMA length, this indicator mathematically aggregates 24 distinct momentum cycles to verify if the entire institutional ecosystem is overextended. It visualizes this data through a dynamically scaling histogram, a multi-ribbon fan, and volatility boundaries.
2. The Core Innovation: How it Calculates Everything
Standard moving averages rely on fixed lookback periods (e.g., a 50-EMA), which inherently lag the market and drop relevant historical data. This script is fundamentally original because it abandons fixed lookbacks in favor of Anomaly Anchoring, Expanding EMA Recursion, and Predictive Classification.
Anomaly Anchoring: The engine constantly scans volume for statistical deviations. When it detects a volume spike exceeding a 2.5 Z-Score, it drops a mathematical "Anchor." It tracks the last 24 of these institutional liquidity events simultaneously.
Expanding EMA Recursion: From each of the 24 anchor points, the script begins calculating an independent EMA. Unlike fixed EMAs, these use an "Expanding Alpha" ($\alpha = 2 / (count + 1)$), making them incredibly sensitive to the initial impulse of a new trend while maintaining the memory of the anchor point.
The Consensus Meta-Mean: The script calculates the absolute average of all 24 active EMA lines. This "Meta-EMA" represents the true equilibrium of the market's current momentum. The distance of price from this average is converted into a Z-Score, standardizing the deviation across any asset class.
The K-Nearest Neighbors (KNN) Engine: When the script detects 100% Consensus (e.g., all 24 active EMAs are simultaneously above or below price), it captures the exact numerical fingerprint of the market (EMA Deviation, EMA Velocity, and Price Velocity). The KNN engine calculates the Euclidean Distance between the current fingerprint and the last 300 historical fingerprints. It finds the 5 nearest neighbors (the 5 times history looked mathematically identical) and checks their win/loss results to generate a live probability score.
3. Justifying the Methodology
Why combine 24 expanding EMAs with a KNN machine learning model? Because fast-moving markets frequently outrun standard indicators.
In high-volatility environments, traditional simple moving averages (SMAs) lag too much to catch the absolute bottom or top. EMAs hug price closer, making them the preferred benchmark for momentum algorithms. By anchoring 24 separate EMAs to actual volume anomalies, we verify if the entire market ecosystem—even the most sensitive momentum metrics—agrees on the overextension. By passing that data through a KNN algorithm, we filter out low-quality traps by asking the data: "The last 5 times momentum snapped this aggressively, did price successfully reverse by at least 0.1%?"
4. How to Use the Indicator
Visual Layout:
The Structural Fan (Ribbons): 24 individual EMA lines plotted on a standardized Z-axis. When tightly compressed, momentum is structurally unanimous. When fanned out, momentum is decaying or conflicted.
The Engine Histogram: Visualizes the standardized deviation of price from the Meta-EMA.
Expansion (Bright): Bright Blue or Bright Lime/Red bars indicate that momentum is actively accelerating away from equilibrium.
Contraction (Dark): Dark, highly transparent bars indicate that momentum is decaying or cooling off back toward the zero-line.
Tactical Trade Execution:
Spot the Momentum Purge: Watch the histogram expand into extreme territory (Lime for bullish potential, Red for bearish potential). Because this is an EMA engine, this happens when price moves faster than the institutional momentum "gas" can follow. Do not enter yet.
Wait for the Machine Learning Confirmation: Wait for the background to flash Lime (Bullish) or Red (Bearish) with a printed percentage (e.g., 80%). This means the KNN algorithm has verified that identical historical momentum snaps successfully reversed price.
The Trigger: Wait for the white Signal Line to peak (often printing an Exhaustion ✧ marker) and begin receding back toward the zero-line, ultimately "re-enveloping" the histogram bars. This confirms that the extreme directional friction has officially snapped, signaling a high-probability mean reversion.
Informacje o Wersji
Blue/Red histogram that matches my other indicatorsSkrypt 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.