Machine Learning Breakouts (from Pivots)
Feb 16, 2024

The Machine Learning Breakouts (from Pivots) indicator utilizes the k-Nearest Neighbors (k-NN) algorithm to identify trend breakout opportunities by forecasting price zones based on historical pivot point data. It provides traders with dynamic support and resistance levels that adapt to market volatility, signaling potential long entries when price crosses above the forecasted high line and short entries when it breaks below the forecasted low line.
Usage
The Usage section describes how the script can be used to identify trend shifts and momentum breakouts. The indicator generates two primary bands on the chart: a green higher band and a red lower band.
- Bullish Breakouts: When the price closes above the green higher band, it suggests a bullish breakout. This indicates that the current price action has surpassed the predicted resistance level calculated from historical pivot highs.
- Bearish Breakouts: When the price closes below the red lower band, it suggests a bearish breakout. This indicates that the price has dropped below the predicted support level derived from historical pivot lows.
- Trend Following: The colored zones between the price and the bands visually highlight the strength of the current trend. A green fill appears during bullish momentum, while a red fill appears during bearish momentum.
Details
The script employs a machine learning approach using the k-Nearest Neighbors (k-NN) method combined with the Euclidean distance algorithm. It operates in a two-dimensional space defined by price and time to analyze the relationship between historical pivot points.
The core logic involves identifying pivot highs and lows over a specified lookback period. The k-NN algorithm then searches for the most similar historical patterns (neighbors) to forecast the current "breakout paths." By using Euclidean distance, the tool measures straight-line distances between data points to ensure the predicted bands accurately reflect the most relevant historical price structures. The calculations are processed via a dedicated library to maintain efficiency while providing smoothed, extrapolated bands that adapt to changing market conditions.
Settings
Input Parameters Settings
- Pivot Bars: Specifies the number of bars required to confirm a pivot point. Higher values result in more significant but fewer pivot points, leading to broader breakout zones.
- Show/Hide Pivots: Toggles the visual display of "H" (High) and "L" (Low) labels on the chart where pivots were detected.
ML Model Settings
- Number of Neighbors (k): Controls how many historical data points are considered for the k-NN prediction. Higher values increase smoothing but may reduce sensitivity to recent shifts.
- Maximum Data Points: Sets the total size of the dataset used for analysis. This balances the depth of historical context against computational performance.
- Prediction Smoothing: Applies a smoothing factor to the forecasted bands to filter out market noise and prevent false signals from minor price fluctuations.
FAQ
How do I interpret the colored zones? The green zone indicates price is trending above the ML-predicted resistance, signaling bullish strength. The red zone indicates price is trending below the ML-predicted support, signaling bearish strength.
What timeframe works best for this indicator? The indicator is designed to be adaptive. However, users should adjust the "Pivot Bars" and "Number of Neighbors" settings to match the volatility of their chosen timeframe.
How can I get access to the Machine Learning Breakouts (from Pivots) tool? 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.