OPEN-SOURCE SCRIPT

Bollinger Cluster Absorption targets [KNN Engine]

817
Bollinger Cluster Absorption [KNN Engine] - On-Chart Visualizer & HUD

This indicator is an advanced, machine-learning-assisted structural mapping tool. It moves beyond traditional momentum oscillators by evaluating standard deviation and mean reversion relative to a dynamically anchored cluster of Bollinger bands, utilizing a 6-Dimensional K-Nearest Neighbors (KNN) classification algorithm.

Operating purely as an on-chart interface and risk management suite, it overlays structural geometries, Maximum Favorable Excursion (MFE) tracking boxes, and simulated Kelly Criterion position sizing directly onto your price chart.

The Core Engine: Dynamic Bollinger Basis Clusters

Unlike standard Bollinger Bands that measure standard deviation over fixed periods (e.g., 20 periods), this engine measures the tension of price relative to an entirely dynamic array of Liquidity Anchors.

Anomaly Detection (The Anchor): The script continuously tracks volume using a rolling Z-score. When a significant institutional liquidity event occurs (volume spikes above your defined Z-score threshold), the script drops an "Anchor."

Dynamic 24x Array: Upon an anchor trigger, the script initializes a new Simple Moving Average (the "Basis" line of a Bollinger Band) from that exact bar. It tracks up to 24 of these anchored basis lines simultaneously, recalculating their averages bar-by-bar.

Z-Score Standardization (Meta-Mean): To distill 24 different basis lines into a single readable metric, the script calculates their cross-sectional average (the "Meta-Mean" of the cluster). It then calculates the Z-Score of the current Price relative to this cluster's mean and standard deviation. This provides a standardized measure of whether price is extremely overbought or oversold compared to the aggregate institutional baseline.

The Machine Learning Module (KNN)

The engine evaluates market conditions by feeding a 6-Dimensional sensory matrix into a K-Nearest Neighbors (KNN) classification algorithm. The six features evaluated are:

Bollinger Deviation (Z-Score): The current standardized distance of price from the dynamic cluster center.

Deviation Velocity: The bar-to-bar momentum of price moving toward or away from the cluster.

Price Velocity: Z-Scored rate of change of price from a baseline 50-SMA.

Cluster Consensus: The ratio of the 24 active basis lines positioned above versus below current price (measuring mean-reversion pressure).

Historical Rate of Change: An 8-bar lookback of the Bollinger Deviation.

Cluster Squeeze (Compression): Standard deviation of the 24 anchors themselves to identify tightly coiled structural energy (the famous "Bollinger Squeeze").

The algorithm maps this 6D state and calculates the Euclidean distance to a memory bank of the last 500 historical setups. It isolates the K most mathematically identical past environments and evaluates their success rates, returning a real-time Probability Score.

On-Chart Visuals & MFE/LFE Box Engine

Rather than cluttering your chart with disjointed arrows, this visualizer groups continuous, same-direction KNN signals into clean structural "Streaks."

Independent Line Mitigation: The AI projects forward-looking target lines (Scalp target and Stop Loss floor). These lines actively track price tick-by-tick. The exact moment price intersects a target, that specific line halts, solidifies, and stops extending, leaving a permanent structural footprint.

Profit Box (Blue): Stretches vertically from your initial entry up to the projected target. It dynamically expands to the right, snapping exactly to the bar that achieved the Maximum Favorable Excursion (MFE).

Risk Box (Red): Drops from the entry to the absolute minimum anchored stop loss, highlighting the exact Lowest Favorable Excursion (LFE) (Maximum Adverse Excursion) of the active structural streak.

Streak Termination: A structural streak only ends when the absolute minimum Stop Loss is breached or an opposing KNN signal flips the mathematical momentum.

The Agent Diagnostic Dashboard (HUD)

The built-in dashboard provides real-time diagnostic transparency into the engine's internal state:

Market Context: Live metrics for Bollinger Deviation (Z), Trend Vector, Cluster Squeeze (Z), and Cluster Consensus.

AI Probability: The live win-rate probability generated by the companion 6D KNN engine.

Live Portfolio Tracking: Simulates a compounding equity curve. It tallies the Hit Rate of the KNN algorithm and computes a simulated dollar PnL based on your starting capital.

Dynamic Bet Sizing (Kelly Criterion): Utilizing the KNN probability and your defined Risk/Reward parameters, the dashboard simulates optimal position sizing via a dampened Kelly Criterion formula. It actively scales simulated risk up during high-probability setups and scales down when the edge decreases, capping at a strict maximum to prevent ruin.

Disclaimer: The portfolio tracker and Kelly sizing metrics are simulated diagnostic tools meant for the educational evaluation of the KNN algorithm's historical efficacy. This tool provides statistical classification of historical data, which does not constitute financial advice, predictive guarantees, or real-world trading results.

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.