kNN Market Architecture

Applies k-Nearest Neighbours ML to classify market structure using volume, pivot points, and volatility features. Automatically detects HH, HL, LH, LL structure in real time across all timeframes.

Machine LearningS&RPro
TradingView

About This Indicator

The kNN Market Architecture indicator uses the k-Nearest Neighbours algorithm to classify current market structure by comparing present conditions to thousands of historical bars across multiple feature dimensions including volume, volatility, momentum, and pivot history.

Rather than using simple swing-high/swing-low detection, this indicator weighs each structural point by its similarity to known HH, HL, LH, LL patterns in history. The result is a more reliable, context-aware structure map that adapts to different market regimes.

Key Features

  • kNN classification of HH, HL, LH, LL structure labels in real time
  • Multi-feature input: volume, ATR, momentum, and pivot geometry
  • Confidence-weighted labels weak structure is visually distinguished
  • Works across all timeframes; performs best on 1H and above
  • Trend bias indicator derived from rolling structure sequence
  • No repainting uses confirmed bar data only

How to Use

  • Use the rolling structure sequence (HH-HL pattern) to confirm uptrend bias
  • Look for LH-LL sequence to confirm downtrend bias before entering short
  • A CHoCH (Change of Character) is signalled when the structure sequence breaks
  • Combine with FVG and order block tools for entry precision
  • Avoid trading low-confidence labels (shown with lighter opacity)