# KNN Supertrend Horizon

KNN Supertrend Horizon is an indicator on [Vela](https://vela.luxalgo.com/chart), our next-generation charting platform, written in Pine Script®.

Filters a Supertrend baseline through a k-nearest-neighbors classifier that checks current RSI and volatility conditions against similar historical bars before confirming direction. Confidence-graded candle coloring, volume-scaled rejection orbs, and a live dashboard complete the read. For trend followers who want fewer, better flips.

- Indicator in the LuxAlgo Library, by LuxAlgo, published Mar 23, 2026.
- Access: free.
- Concepts: [Supertrend](https://www.luxalgo.com/library/concept/supertrend/) (primary), [kNN Analog Forecasting](https://www.luxalgo.com/library/concept/knn-analog-forecasting/)
- Open on Vela: https://vela.luxalgo.com/chart?pineScriptCodeId=cmpwn2twb003xvhsg91g1p6vs
- Page: https://www.luxalgo.com/library/indicator/knn-supertrend-horizon/

**KNN Supertrend Horizon** wraps a [Supertrend](https://www.luxalgo.com/library/concept/supertrend/) baseline in a machine-learning filter. A k-nearest-neighbors model encodes RSI and ATR-based volatility, finds the most similar bars inside the Search Window, the logic of [kNN analog forecasting](https://www.luxalgo.com/library/concept/knn-analog-forecasting/), and classifies conditions as bullish or bearish. The colored horizon, the candle colors and the Supertrend line color follow that vote, smoothed and held by the ML Confidence Buffer, rather than the raw Supertrend flip.

## How to Trade the KNN Supertrend Horizon?

- **Bullish horizon**: the classifier's vote is bullish: context for trend entries and pullbacks toward the trend level.
- **Bearish horizon**: the vote is bearish, the mirror case.
- **Fading gradient colors**: the Liquid Smooth candle coloring mutes as model confidence drops: fatigue, indecision, or consolidation worth sitting out.
- **3D Rejection Orbs**: printed when a candle rejects the trend level with a meaningful wick; size scales with relative volume and a label reports the candle's volume.
- **Dashboard**: direction, model confidence, and relative volatility in one panel.

The ML Confidence Buffer holds flips back until the classification moves decisively past the midpoint, keeping the horizon steadier than stop-and-reverse logic alone.

## KNN Supertrend Horizon Settings

- **K-Neighbors** and **Search Window**: neighbors per classification and how much history is scanned.
- **ATR Length** and **Factor**: the Supertrend baseline's volatility lookback and multiplier.
- **Smooth Price Input**: HMA smoothing of the price feeding the model's features.
- **ML Confidence Buffer (%)**: how far past the midpoint probability the signal must move before a flip is accepted.
- **Show 3D Rejection Orbs**, **Min Wick-to-Body Multiplier**, and **Min Bubble Gap**: rejection toggle, wick requirement, and orb spacing.
- **Liquid Smoothness**, **Vibrancy**, **Show Dashboard**: smoothing of the classifier probability that drives both flips and the gradient, gradient intensity, and the stats panel.

## Frequently Asked Questions

### What does it add over a classic build?

Our standalone [Supertrend indicator](https://www.luxalgo.com/library/indicator/supertrend/) flips whenever price crosses the ATR-trailed line. This version demands statistical agreement from similar historical conditions first, then layers on rejection orbs, confidence gradients, and the dashboard.

### What are the 3D Rejection Orbs telling me?

Each orb marks a candle that rejected the trend level with a pronounced wick, sized by the relative volume behind the reaction. Larger orbs mean higher-interest rejections, candidates for pullback entries or for tightening risk.

### How do I access KNN Supertrend Horizon?

It is free within the LuxAlgo Library. You can also test it in Quant, our coding agent, without leaving this page. You can also copy the source code from this page and run it anywhere Pine Script® runs.

## Related indicators

- [Supertrend Channels](https://www.luxalgo.com/library/indicator/supertrend-channels/) (Supertrend): markdown at https://www.luxalgo.com/library/indicator/supertrend-channels.md
- [SuperTrend Oscillator](https://www.luxalgo.com/library/indicator/supertrend-oscillator/) (Supertrend): markdown at https://www.luxalgo.com/library/indicator/supertrend-oscillator.md
- [SuperTrend Recovery](https://www.luxalgo.com/library/indicator/supertrend-recovery/) (Supertrend): markdown at https://www.luxalgo.com/library/indicator/supertrend-recovery.md
- [SuperTrend AI (Clustering)](https://www.luxalgo.com/library/indicator/supertrend-ai-clustering/) (Supertrend): markdown at https://www.luxalgo.com/library/indicator/supertrend-ai-clustering.md
- [SuperTrend Polyfactor Oscillator](https://www.luxalgo.com/library/indicator/supertrend-polyfactor-oscillator/) (Supertrend): markdown at https://www.luxalgo.com/library/indicator/supertrend-polyfactor-oscillator.md
- [Supertrend Parameter Sensitivity 3D](https://www.luxalgo.com/library/indicator/supertrend-parameter-sensitivity-3d/) (Supertrend): markdown at https://www.luxalgo.com/library/indicator/supertrend-parameter-sensitivity-3d.md
- [The Echo Forecast](https://www.luxalgo.com/library/indicator/the-echo-forecast/) (kNN Analog Forecasting): markdown at https://www.luxalgo.com/library/indicator/the-echo-forecast.md
- [Historical Price Projection](https://www.luxalgo.com/library/indicator/historical-price-projection/) (kNN Analog Forecasting): markdown at https://www.luxalgo.com/library/indicator/historical-price-projection.md

---

Source: https://www.luxalgo.com/library/indicator/knn-supertrend-horizon/ (LuxAlgo Library). Free to use with attribution: https://www.luxalgo.com/library/license/
