Reversal Probability & Signals
Apr 17, 2026

The Reversal Probability & Signals indicator provides a real-time estimation of the likelihood of market tops and bottoms by utilizing a simplified K-Nearest Neighbors (KNN) machine learning algorithm.
Usage
The Reversal Probability & Signals tool can be used to identify high-probability reversal zones and specific entry triggers. It functions as a pattern recognition engine that compares current momentum against historical reversal states.
- Identifying Exhaustion: When the probability histogram rises above the Upper Threshold (default 80%), the market is entering a state that historically precedes a pivot. Users should observe this as a "standby" phase.
- Triggering Entries: A signal is generated when the probability peaks above the threshold and subsequently falls below the Lower Threshold. This confirms that the extreme momentum has shifted, suggesting the reversal is underway.
- Target Selection: Users can toggle the indicator between "BOTTOM" (to find long entries at pivot lows) or "TOP" (to find short entries at pivot highs).
Details
The script utilizes a KNN classification model built in Pine Script. It processes data through three distinct stages:
- Feature Extraction: It calculates eight different lengths of the Commodity Channel Index (CCI), ranging from short-term (20) to long-term (400) periods, to create a multi-dimensional momentum profile.
- Training Data: The script identifies historical pivot points (Top/Bottom) and stores the corresponding CCI values. It also collects random non-pivot samples to ensure a balanced dataset.
- Euclidean Distance: For every new bar, the algorithm calculates the mathematical distance between current CCI values and the stored historical samples. The output probability represents the percentage of the "K" nearest neighbors that were actual historical reversals.
Settings
General Settings
- Prediction Target: Choose between predicting market BOTTOMS (Pivot Lows) or TOPS (Pivot Highs).
Feature Parameters (CCI)
- CCI Lengths 1-8: Adjustable periods for the momentum features used in the KNN model.
KNN Model Settings
- KNN K-Value: The number of nearest neighbors to compare. The script dynamically scales this value as the database grows.
- Max Samples per Class: The maximum memory limit for stored historical data points.
Pivot Definition
- Pivot Left/Right Bars: Determines the lookback and lookahead required to confirm a structural pivot point.
Signal Settings
- Signal Upper Threshold: The probability level required to enter the "standby" state.
- Signal Lower Threshold: The probability level required to trigger the actual signal after being in standby.
- ATR Offset: Controls the vertical distance of the signal shapes from the price bars.
FAQ
How do I use the "Standby" vs "Trigger" logic?
The "Standby" occurs when the probability exceeds the upper threshold (e.g., 80%), signaling extreme conditions. The "Trigger" occurs only after the probability then drops below the lower threshold, confirming a change in momentum.
Why does the indicator take time to show accurate probabilities?
Because the KNN model "learns" from the current chart's history, it needs to collect enough pivot samples to build a reliable database. The "K" value scales dynamically as more data is collected.
How can I access this indicator?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.