OPEN-SOURCE SCRIPT
Trend detection zero lag

Trend Detection Zero-Lag (v6)
Trend Detection Zero-Lag is a high-performance trend identification indicator designed for intraday traders, scalpers, and swing traders who require fast trend recognition with minimal lag. It combines a zero-lag Hull Moving Average, slope analysis, swing structure logic, and adaptive volatility sensitivity to deliver early yet stable trend signals.
This indicator is optimized for real-time decision-making, particularly in fast markets where traditional moving averages react too slowly.
Core Features
🔹 Zero-Lag Trend Engine
Uses a Zero-Lag Hull Moving Average (HMA) to reduce lag by approximately 40–60% versus standard moving averages.
Provides earlier trend shifts while maintaining smoothness.
🔹 Multi-Factor Trend Detection
Trend direction is determined using a hybrid engine:
HMA slope (momentum direction)
Rising / falling confirmation
Swing structure detection (HH/HL vs LH/LL)
ATR-adjusted dynamic sensitivity
This approach allows fast flips when conditions change, without excessive noise.
Adaptive Volatility Sensitivity
Sensitivity dynamically adjusts based on ATR relative to price
In high volatility: faster reaction
In low volatility: smoother, more stable trend state
This ensures the indicator adapts across:
Trend days
Range days
Volatility expansion or contraction
Trend Duration Intelligence
The indicator tracks historical trend durations and maintains a rolling memory of recent bullish and bearish phases.
From this, it calculates:
Current trend duration
Average historical duration for the active trend direction
This helps traders gauge:
Whether a trend is early, mature, or extended
Probability of continuation vs exhaustion
Strength Scoring
A normalized Trend Strength Score (0–100) is calculated using:
Zero-lag slope magnitude
ATR normalization
This provides a quick read on:
Weak / choppy trends
Healthy trend continuation
Overextended momentum
Visual Design
Color-coded Zero-Lag HMA
Bullish trend → user-defined bullish color
Bearish trend → user-defined bearish color
Designed for dark mode / neon-style charts
Clean overlay with no clutter
Trend Detection Zero-Lag is built for traders who need:
Faster trend recognition
Adaptive behavior across market regimes
Structural confirmation beyond simple moving averages
Clear, actionable visual signals
Trend Detection Zero-Lag is a high-performance trend identification indicator designed for intraday traders, scalpers, and swing traders who require fast trend recognition with minimal lag. It combines a zero-lag Hull Moving Average, slope analysis, swing structure logic, and adaptive volatility sensitivity to deliver early yet stable trend signals.
This indicator is optimized for real-time decision-making, particularly in fast markets where traditional moving averages react too slowly.
Core Features
🔹 Zero-Lag Trend Engine
Uses a Zero-Lag Hull Moving Average (HMA) to reduce lag by approximately 40–60% versus standard moving averages.
Provides earlier trend shifts while maintaining smoothness.
🔹 Multi-Factor Trend Detection
Trend direction is determined using a hybrid engine:
HMA slope (momentum direction)
Rising / falling confirmation
Swing structure detection (HH/HL vs LH/LL)
ATR-adjusted dynamic sensitivity
This approach allows fast flips when conditions change, without excessive noise.
Adaptive Volatility Sensitivity
Sensitivity dynamically adjusts based on ATR relative to price
In high volatility: faster reaction
In low volatility: smoother, more stable trend state
This ensures the indicator adapts across:
Trend days
Range days
Volatility expansion or contraction
Trend Duration Intelligence
The indicator tracks historical trend durations and maintains a rolling memory of recent bullish and bearish phases.
From this, it calculates:
Current trend duration
Average historical duration for the active trend direction
This helps traders gauge:
Whether a trend is early, mature, or extended
Probability of continuation vs exhaustion
Strength Scoring
A normalized Trend Strength Score (0–100) is calculated using:
Zero-lag slope magnitude
ATR normalization
This provides a quick read on:
Weak / choppy trends
Healthy trend continuation
Overextended momentum
Visual Design
Color-coded Zero-Lag HMA
Bullish trend → user-defined bullish color
Bearish trend → user-defined bearish color
Designed for dark mode / neon-style charts
Clean overlay with no clutter
Trend Detection Zero-Lag is built for traders who need:
Faster trend recognition
Adaptive behavior across market regimes
Structural confirmation beyond simple moving averages
Clear, actionable visual signals
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.