# kNN Market Architecture

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

Maps short, medium, and long-term market structure from pivots detected at three nested, volatility-scaled lookbacks (base, 3x and 9x). Delta Tank labels estimate buying and selling pressure at unbroken levels from candle-signed volume, and an anchored volume profile covers the active range. A structure suite for traders who pair levels with participation.

- Indicator in the LuxAlgo Library, by LuxAlgo, published Mar 16, 2026.
- Access: free.
- Concepts: [kNN Analog Forecasting](https://www.luxalgo.com/library/concept/knn-analog-forecasting/) (primary), [Swing Structure Grammar](https://www.luxalgo.com/library/concept/swing-structure-grammar/)
- Open on Vela: https://vela.luxalgo.com/chart?pineScriptCodeId=cmpwn2ta6003wvhsg8sq5komo
- Page: https://www.luxalgo.com/library/indicator/knn-market-architecture/

**kNN Market Architecture** draws a three-layer map of market structure (short, medium, and long-term) and lets a [k-nearest neighbors](https://www.luxalgo.com/library/concept/knn-analog-forecasting/) model decide which pivots earn a place on it. Each candidate pivot is described by features such as relative ATR and volume, compared with a record of historical pivots, and plotted only when its nearest neighbors clear the Confidence Threshold. In the current version every stored pivot carries the same score, so the check rarely rejects anything and the map is shaped mainly by the three pivot lookbacks.

## How to Trade the kNN Market Architecture?

- **Bias by layer**: pick ST, MT, or LT as the Bias Source. Above the layer's most recent pivot high the read is bullish, below its most recent pivot low bearish.
- **Breaks of structure**: a validated level giving way signals continuation; keeping all three layers visible gives top-down alignment on one chart.
- **Delta Tank**: labels at unbroken levels accumulate total volume, delta, and the delta-to-volume ratio. A filling green tank shows buyers active at the level, a red one warns it may break.
- **Anchored volume profile**: spans the active range between the bias layer's most recent pivot high and low, exposing where volume concentrated inside the current structure.

With Auto-Adjust Sensitivity enabled, the detection window scales with an ATR ratio, expanding in hot volatility so only larger moves qualify, contracting in quiet tape.

## kNN Market Architecture Settings

- **Structure Sensitivity**: sets the base pivot lookback inversely (11 minus the setting, at least 3 bars), so higher values mean shorter lookbacks and more pivots.
- **Auto-Adjust Sensitivity**: volatility-based scaling of the detection window.
- **k-Nearest Neighbors**: how many of the closest stored pivots (up to 100 kept per side and layer) are averaged to score each candidate.
- **Confidence Threshold**: minimum average neighbor score a pivot needs to plot; because stored pivots all score 1.0, it only holds back each layer's warm-up pivots, and only when set above 0.5.
- **ST / MT / LT Toggles**, **Bias Source**, and **Color Candles by Bias**: layer visibility, the bias driver, and gradient candle coloring.
- **Show Volume Profile**, **Profile Rows**, and **Profile Width (%)**: the anchored profile and its resolution.

## Frequently Asked Questions

### What does the kNN validation actually reject?

In the current version, almost nothing: every stored pivot carries the same score, so the check does not reject pivots on their volatility or volume signature. A Confidence Threshold above 0.5 only holds back each layer's first few pivots while its history builds; at 0.5 or below, every detected pivot plots.

### Are there other LuxAlgo tools built on the same method?

Yes. [KNN Supertrend Horizon](https://www.luxalgo.com/library/indicator/knn-supertrend-horizon/) applies the same nearest-neighbor classification to trend-following. There it filters a volatility-trailing baseline rather than structural pivots.

### How can I access the kNN Market Architecture?

Free, via the LuxAlgo Library. The indicator can also be launched in Quant, our coding agent, from this page to explore the layers and settings live. You can also copy the source code from this page and run it anywhere Pine Script® runs.

## Related indicators

- [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
- [Indicator Configuration Forecasting](https://www.luxalgo.com/library/indicator/indicator-configuration-forecasting/) (kNN Analog Forecasting): markdown at https://www.luxalgo.com/library/indicator/indicator-configuration-forecasting.md
- [KNN Supertrend Horizon](https://www.luxalgo.com/library/indicator/knn-supertrend-horizon/) (kNN Analog Forecasting): markdown at https://www.luxalgo.com/library/indicator/knn-supertrend-horizon.md
- [Neighboring Trailing Stop](https://www.luxalgo.com/library/indicator/neighboring-trailing-stop/) (kNN Analog Forecasting): markdown at https://www.luxalgo.com/library/indicator/neighboring-trailing-stop.md
- [MACD Based Price Forecasting](https://www.luxalgo.com/library/indicator/macd-based-price-forecasting/) (kNN Analog Forecasting): markdown at https://www.luxalgo.com/library/indicator/macd-based-price-forecasting.md
- [Swing Structure Scanner](https://www.luxalgo.com/library/indicator/swing-structure-scanner/) (Swing Structure Grammar): markdown at https://www.luxalgo.com/library/indicator/swing-structure-scanner.md
- [HTF Swing Structure Signals](https://www.luxalgo.com/library/indicator/htf-swing-structure-signals/) (Swing Structure Grammar): markdown at https://www.luxalgo.com/library/indicator/htf-swing-structure-signals.md

---

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