Lorentzian Key Support and Resistance Level Detector
Aug 2, 2025

The Lorentzian Key Support and Resistance Level Detector indicator identifies robust price zones using advanced mathematical clustering. By utilizing Lorentzian distance rather than traditional Euclidean metrics, the tool effectively ignores market outliers and flash spikes, focusing instead on price areas where the most trading activity actually occurs.
Usage
The indicator can be used to automatically identify key support and resistance levels on any timeframe. Traders can utilize these levels as targets for take-profits or as zones for potential trend reversals.
- Auto K-Selection: When enabled, the script uses the "Elbow Method" to statistically determine the optimal number of support and resistance levels for the current market context.
- Deviation Bands: These bands visualize the spread of price action around a cluster center. Narrower bands typically indicate stronger, more concentrated support or resistance.
- Strength Scores: Each level is assigned a reliability score. Scores above 0.8 indicate very strong clustering, while lower scores suggest weaker levels that should be approached with caution.
- Multi-Timeframe (MTF) Analysis: Users can select a higher timeframe for detection to find major institutional S/R levels while trading on a lower timeframe.
Details
Traditional K-means clustering often fails in financial markets because it uses Euclidean distance, which squares differences. This means a single 5% price spike has 25 times the influence of a 1% move, pulling S/R lines toward outliers.
This script solves this by implementing Lorentzian Distance. This logarithmic approach compresses large price differences, ensuring that flash spikes do not dominate the calculation. Consequently, the clusters stay centered where prices actually trade. Furthermore, the algorithm incorporates a self-calibrating $\sigma$ parameter based on market entropy, allowing it to automatically adapt its sensitivity to current volatility levels.
Settings
- Clustering Settings
- Auto K-Levels Selection: Enables the Elbow Method with Sharpness Heuristic to choose the number of levels.
- Manual K-Levels: Sets a fixed number of clusters (2-6) if Auto selection is disabled.
- Sample Size: The number of recent bars used for calculation (recommended 50-150 for low TFs, 150+ for high TFs).
- Multi-Timeframe Settings
- Timeframe for S/R Detection: Allows the selection of a higher timeframe for level calculation.
- Display Settings
- Show Cluster Bands: Toggles the visibility of the deviation areas around S/R lines.
- Show Metrics Table/WCSS Analysis: Toggles the data tables that explain the statistical choices made by the algorithm.
FAQ
How do I interpret the WCSS Analysis table?
The table shows the "Within-Cluster Sum of Squares" for different K values. A significant drop in WCSS combined with high "Sharpness" indicates the optimal number of levels (the "elbow" point).
What is the advantage of Lorentzian distance over standard S/R lines?
Lorentzian distance is outlier-resistant. While standard indicators might shift their levels due to a random wick or news spike, this indicator remains anchored to the price zones where the most volume and time were spent.
How do 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.