Market Structure - HH, HL, LH, LL with Trendlines & Alerts
Apr 11, 2025

The Market Structure - HH, HL, LH, LL with Trendlines & Alerts indicator is a comprehensive technical analysis tool designed to automatically identify and label significant swing points to help traders visualize price action trends.
Usage
The tool is primarily used to identify the current phase of market structure by labeling pivot points as Higher Highs (HH), Higher Lows (HL), Lower Highs (LH), or Lower Lows (LL).
- Uptrend Identification: A sequence of Higher Highs followed by Higher Lows suggests a bullish market environment.
- Downtrend Identification: A sequence of Lower Lows followed by Lower Highs indicates a bearish market environment.
- Reversal Signals: A Lower High forming after a series of Higher Highs can provide an early warning of a potential trend exhaustion or reversal.
The script automatically draws trendlines connecting these pivot points, providing immediate visual feedback on the slope and intensity of the current trend.
Details
The script utilizes the ta.pivothigh and ta.pivotlow functions to detect peaks and troughs. A unique aspect of this implementation is its dynamic pivot length adjustment. Instead of a static value, the script scales the lookback period based on the chart's timeframe (e.g., 5 bars for 15m, 10 bars for Daily), ensuring that market structure detection remains relevant whether you are scalping or position trading.
When a new swing point is confirmed (after the specified pivot length has passed), the script evaluates it against the previous confirmed swing point to determine its classification. It then generates a label and a trendline connecting the old point to the new one.
Settings
As this version uses an automated logic for timeframe detection, the primary parameters are handled internally:
- Pivot Length: Automatically scales based on the chart timeframe (15m, 30m, 1h, 4h, and Daily) to ensure optimal swing detection.
- Visual Colors: Bullish structures (HH/LH) are typically highlighted in green, while bearish structures (HL/LL) are highlighted in red.
FAQ
How do I use the alerts?
You can set up alerts through the TradingView alert menu. The script includes conditions for HH, LH, HL, and LL detections, allowing you to be notified the moment a market structure shift is confirmed on the chart.
Why do the labels appear a few bars late?
The labels rely on pivot points, which require a certain number of bars to close to either side of the high/low to confirm it is a significant swing point. This prevents "repainting" and ensures the structure identified is valid.
How can I access Market Structure - HH, HL, LH, LL with Trendlines & Alerts?
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.