Machine Learning Key Levels
Jul 3, 2025

The Machine Learning Key Levels indicator plots significant price levels on your chart by detecting historical pivot points and grouping them using agglomerative clustering. This tool provides an adaptive way to visualize price zones where historical activity has concentrated, helping traders identify potential support and resistance areas based on statistical density rather than simple price touches.
Usage
The script identifies pivot highs and lows over a specified lookback period and stores them for analysis. Using hierarchical clustering, it merges these points into distinct levels.
- Identifying Support and Resistance: The horizontal lines represent the calculated key levels. Labels next to each level indicate its "strength," which can be displayed as a percentage of total pivots or a raw count.
- Adaptive Levels: By enabling the Auto No. Levels setting, the indicator uses the silhouette method to automatically determine the most mathematically sound number of clusters for the current market structure.
- Pivot Visualization: If enabled, circles appear on the chart where pivots were detected, color-coded to match the cluster (level) they belong to. This helps visualize how the machine learning model grouped specific price actions.
Details
Agglomerative clustering is a bottom-up machine learning method. It starts by treating every detected pivot as its own cluster and then iteratively merges the closest pairs based on "average linkage" (the average distance between all points in two clusters).
Unlike K-means clustering, which requires a pre-defined number of clusters (K), this hierarchical approach allows for a more flexible interpretation of price data. The script utilizes the Silhouette Method to score different cluster configurations; a higher silhouette score indicates that the levels are well-separated and that price points within each level are tightly grouped, signifying a "cleaner" and potentially more reliable key level.
Settings
Clustering
- Pivot Length: The number of bars required on either side of a high or low to confirm a pivot point.
- Pivot Memory: The maximum number of historical pivots stored in memory for the clustering engine. Higher values provide more historical depth but may impact performance.
- Number of Levels: The fixed number of key levels to display when the automatic selection is disabled.
- Auto No. Levels: When enabled, the script automatically selects the optimal number of levels using the silhouette method.
Display
- Show Pivot Circles: Toggles the visibility of markers at the original pivot locations.
- Level Glow: Adds a visual glow effect to the horizontal lines to highlight the zones.
- Display Strength As: Determines whether the level strength labels show a percentage of total pivots or the raw pivot count.
Metrics Table
- Show Metrics Table: Displays a table on the chart containing data such as the total pivot count, cluster count, and the silhouette score.
- Table Text Size / Position: Customizes the appearance and location of the metrics information.
FAQ
How do I interpret the strength of a level?
The strength is determined by the number of pivots that fall within that specific cluster. A higher percentage or count indicates that the price has reacted to that specific zone more frequently in the past.
Why do the levels move or change?
As new price data is formed and new pivots are detected, the clustering engine re-calculates the optimal averages. Because the "Pivot Memory" is a sliding window, older pivots are dropped as new ones are added, causing the levels to adapt to recent market structure.
How can I access the Machine Learning Key Levels?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Trading & investing are risky and many will lose money in connection with trading and investing activities. All content on this site is not intended to, and should not be, construed as financial advice. Decisions to buy, sell, hold or trade in securities, commodities and other investments involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results.
Hypothetical or Simulated performance results have certain limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, including, but not limited to, lack of liquidity. Simulated trading programs in general are designed with the benefit of hindsight, and are based on historical information. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.
Testimonials appearing on this website may not be representative of other clients or customers and is not a guarantee of future performance or success.
As a provider of technical analysis tools and strategies, we do not have access to the personal trading accounts or brokerage statements of our customers. As a result, we have no reason to believe our customers perform better or worse than traders as a whole based on any content, tool, or platform feature we provide.
Charts used on this site are by TradingView in which the majority of our technical indicators are built on. TradingView® is a registered trademark of TradingView, Inc. www.TradingView.com TradingView® has no affiliation with the owner, developer, or provider of the Services described herein.
Market data is provided by CBOE, CME Group, BarChart, Massive, CoinAPI. Select U.S. equities data is provided through Massive. CBOE BZX real-time U.S. equities data is licensed from CBOE and provided through BarChart. Real-time futures data is licensed from CME Group and provided through BarChart. Select cryptocurrency data, including major coins, is provided through CoinAPI. All data is provided “as is” and should be verified independently for trading purposes.
This does not represent our full Disclaimer. Please read our full disclaimer.
© 2026 LuxAlgo Global, LLC.

