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 de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que la republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como asesoramiento o recomendaciones financieras, de inversión, de trading o de otro tipo proporcionadas o respaldadas por TradingView. Más información en Condiciones de uso.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que la republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como asesoramiento o recomendaciones financieras, de inversión, de trading o de otro tipo proporcionadas o respaldadas por TradingView. Más información en Condiciones de uso.