EMA HH/LL Levels v6This indicator builds dynamic horizontal levels based on Higher Highs (HH) and Lower Lows (LL) of an Exponential Moving Average (EMA) rather than raw price.
It is designed to highlight structural EMA-based resistance and support levels and automatically manage their lifecycle.
🔹 Core Logic
The script calculates an EMA (default length: 26).
Pivot Highs and Pivot Lows are detected directly on the EMA line, not on price.
Each confirmed:
EMA Higher High (HH) → creates a solid blue horizontal level
EMA Lower Low (LL) → creates a solid red horizontal level
Levels extend to the right and remain active until specific conditions are met.
🔹 Level State Management
Each level can be in one of three states:
Active (Solid line)
The level has been created but not interacted with yet.
Touched by Price (Dotted line)
When a price bar touches the level (High ≥ level AND Low ≤ level),
the level changes its style from solid to dotted, but remains on the chart.
Broken by EMA (Removed)
When the EMA itself crosses the level:
HH level → removed when EMA crosses above it
LL level → removed when EMA crosses below it
The level is then deleted from the chart.
⚠️ Important:
Levels are never removed by price action alone — only by an EMA break.
🔹 EMA Visualization
The EMA line is color-coded by direction:
Upward slope → user-defined “up” color
Downward slope → user-defined “down” color
EMA length, colors, and line width are fully configurable.
🔹 Customization Options
EMA length
EMA up/down colors and thickness
Pivot sensitivity (left/right bars)
HH / LL level colors and thickness
Maximum number of stored levels (to control memory and chart clutter)
🔹 Use Cases
Identifying EMA-based dynamic support and resistance
Tracking trend structure via EMA swings
Confluence with price action, pullbacks, and breakouts
Trend-following and mean-reversion strategies
🔹 Notes
This indicator works on all markets and timeframes.
No repainting after pivot confirmation.
No ta.crossover() / ta.crossunder() is used — all logic is calculated manually for maximum stability in Pine Script v6.
Pine Script® Indikator






















