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 aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.