Trend Velocity Channel [BackQuant]Trend Velocity Channel
Overview
Trend Velocity Channel is a trend and momentum-acceleration overlay built around one idea, trend strength is the gap between a fast “lead” average and a slow “lag” average . When the lead line pulls away from the lag line, the market is accelerating in that direction. When that gap collapses, trend energy is fading and reversals become more likely.
Instead of using a single moving average slope or crossover, this indicator measures:
A leading trend line (DEMA) that reacts quickly.
A lagging trend line (slower EMA) that represents slower consensus value.
A normalized “velocity / crush” metric: the distance between them in ATR units .
A trend regime based on the sign of that velocity.
A dynamic channel defined by the lead line on one side and a padded lag boundary on the other.
A reversal level engine that marks flip bars and tracks retests and invalidations.
The result is a channel that visually answers:
Are we accelerating or decelerating?
How strong is the current acceleration relative to recent history?
Where is the “danger edge” where a reversal would be confirmed?
Which flip levels remain relevant and which got invalidated?
Concept: lead vs lag as a proxy for trend velocity
Markets trend when price doesn’t just move, it keeps moving faster than the slow baseline can follow . If a fast estimator (lead) separates from a slow estimator (lag), that separation is a practical proxy for “velocity”:
Lead above lag, bullish acceleration.
Lead below lag, bearish acceleration.
Lead converging back into lag, trend energy compressing.
This script calls that separation Crush , meaning the lead line is “crushing away” from the lag line.
Core components
1) Leading line: DEMA
The lead line is a Double Exponential Moving Average:
dema = DEMA(price, maLen)
Why DEMA:
It reduces lag relative to a standard EMA.
It reacts faster to genuine directional moves.
It still smooths noise enough to act as a structural line.
DEMA is used as the “inner” channel edge and the glow anchor.
2) Lagging line: Slow EMA
The lag line is a slower EMA:
lagMA = EMA(price, round(maLen * 1.5))
Why a slower EMA:
It represents a slower-moving consensus baseline.
It creates a meaningful “gap” against the lead line.
It is less sensitive to micro-chop, so separation signals are cleaner.
The lag line also becomes the basis for the channel’s outer edge.
3) Volatility normalization: ATR
Raw MA distance is not comparable across regimes. A 50-point gap might be huge in a low-vol market and nothing in a high-vol market. So the gap is normalized by ATR:
atr = ATR(14)
rawCrush = (dema - lagMA) / atr
Interpretation:
rawCrush = “how many ATRs the lead line is away from the lag line.”
This standardizes the signal across instruments and volatility states.
4) Crush smoothing
The gap can still jitter, especially in choppy markets. So it is EMA-smoothed:
crush = EMA(rawCrush, crushSmth)
Lower crushSmth:
Faster regime flips, more noise.
Higher crushSmth:
More stable regimes, slower reaction.
Trend regime and flips
Trend direction is derived directly from the sign of the smoothed crush:
trend = crush > 0 ? +1 : -1
flip = trend != trend
Meaning:
Bull regime: lead (DEMA) is above lag baseline in ATR units.
Bear regime: lead is below lag baseline.
Flip: the velocity sign changed, meaning acceleration has switched direction.
This is not a price crossover system, it is a lead-lag separation regime system .
Measuring strength: crushNorm
The script also grades how extreme current crush is relative to recent conditions:
crushAbs = abs(crush)
crushHigh = highest(crushAbs, 80)
crushNorm = crushHigh > 0 ? min(crushAbs / crushHigh, 1) : 0
Interpretation:
crushNorm near 0 means separation is small relative to recent extremes, trend is weak or compressing.
crushNorm near 1 means separation is near the largest seen recently, trend acceleration is strong.
This strength scale drives:
Color intensity (gradient)
Glow width
“Peak Crush” alert condition
Channel construction
Inner edge
The inner edge is the leading line:
inner = dema
This is the “fast structure” of the move.
Outer edge
The outer edge is built from the lag line plus an ATR padding:
outer = (bull) lagMA - atr * chanPad
outer = (bear) lagMA + atr * chanPad
This is important. The lag line sits behind price, so the script offsets it outward by a user-defined fraction of ATR. This creates a more realistic boundary that accounts for volatility.
Interpretation:
In bull regimes, the outer boundary is below lagMA, creating a support-like corridor beneath price.
In bear regimes, the outer boundary is above lagMA, creating a resistance-like corridor above price.
The channel is intentionally asymmetric
This channel is not “± ATR around a mean.” It is directional:
Inner edge hugs price via fast DEMA.
Outer edge is anchored to lagMA and padded outward.
So it behaves like a trend corridor where:
The inner edge shows where the trend is currently “being pulled.”
The outer edge shows the boundary where the trend would be meaningfully compromised if crossed.
Ribbon fill (3-layer depth)
Two midpoints are created between inner and outer:
mid1 = inner + (outer - inner) * 0.33
mid2 = inner + (outer - inner) * 0.66
Then the fill is layered:
inner → mid1 (most opaque)
mid1 → mid2
mid2 → outer (most transparent)
This creates a depth effect that visually communicates where price is sitting within the corridor. When the corridor is tight and strong, the ribbon looks concentrated. When it expands, the ribbon spreads and fades.
Color logic (trend + strength)
The indicator uses a gradient color where direction sets the palette and crushNorm sets intensity:
Bull: faint green → strong green as crushNorm increases
Bear: faint red → strong red as crushNorm increases
This means you can read two things instantly:
Direction (bull vs bear)
Acceleration strength (faded vs intense)
Glow engine on DEMA
Glow width scales with ATR and crushNorm:
glowW = atr * 0.07 * (0.5 + crushNorm)
So:
High acceleration = larger glow, more “energy” around the lead line.
Low acceleration = smaller glow.
Glow is built as multiple invisible plots above and below DEMA with layered fills, forming a halo around the lead line that encodes strength.
Flip-aware band breaking
The outer boundary line is broken on flips:
bandBrk = flip ? na : outer
plot(..., plot.style_linebr)
This prevents a misleading continuous line across regime changes, since the outer edge swaps sides on flip.
Crush reversal levels (flip levels engine)
This script includes a level system that plants a dashed horizontal level on every regime flip, then tracks:
Whether price retests it (first touch marker)
Whether price invalidates it (deletes it)
How long it extends forward
How many levels are kept
1) Level placement
On a flip:
If trend flips bullish, the level is placed at the flip bar’s low.
If trend flips bearish, the level is placed at the flip bar’s high.
That makes sense structurally:
Bull flip low is a “pivot low” candidate.
Bear flip high is a “pivot high” candidate.
Then a dashed line is drawn forward ~60 bars.
2) Level storage and maxLvls
Levels are stored in an array and capped by maxLvls. When the cap is exceeded, the oldest is deleted. This keeps the chart readable.
3) Level invalidation (broken logic)
Each level is monitored:
Bull flip level breaks if price closes far below it: close < level - atr * 2.5
Bear flip level breaks if price closes far above it: close > level + atr * 2.5
This is a volatility-scaled invalidation. If price pushes through a flip level by a large margin in ATR terms, it’s no longer acting like a meaningful reaction point.
4) Retest detection
A “touch” is detected when:
close is within 0.25 ATR of the level,
and close two bars ago was not close (distance > 0.5 ATR),
and the level hasn’t been marked retested yet.
On first retest, an “x” marker is printed and the level’s retested flag is set to true so it won’t spam.
What these levels represent
They are not generic support/resistance. They are regime pivot levels created by a change in lead-lag acceleration. In practice:
Untested flip levels can act like “memory zones” where price may react.
Retested levels become less special, still relevant but not “naked.”
Invalidated levels are removed to reduce noise.
Signals and alerts
The script provides:
Crush Bull: flip into bullish regime (crush crosses above 0 via smoothing logic)
Crush Bear: flip into bearish regime
Peak Crush: crushNorm > 0.85, meaning separation is near recent max, strong acceleration
Important: Peak Crush is not a reversal call. It flags strong trend energy. That can precede continuation or exhaustion, you use it as context, not a standalone trade trigger.
How to use it
Trend following framework
Stay aligned with the regime color.
In bull regime, treat the outer boundary as the “structure floor.”
In bear regime, treat the outer boundary as the “structure ceiling.”
The inner DEMA is your fast guide, the outer edge is your compromise boundary.
Acceleration read
Increasing color intensity and thicker glow imply acceleration is strengthening.
Fading color and shrinking glow imply acceleration is decaying and the move is losing energy.
A regime flip is a clean state change, not a micro-signal.
Using reversal levels
Treat naked flip levels as potential reaction zones.
Watch first retest behavior, clean rejection suggests the flip level is holding.
If the level invalidates by 2.5 ATR, it’s removed because structure has been overwritten.
Key inputs explained
MA Length (maLen)
Sets both the lead line length and the lag line length (scaled by 1.5). Lower values:
More sensitive, more flips.
Higher values:
Smoother, fewer flips, slower response.
Crush Smoothing (crushSmth)
Controls stability of the velocity signal. Lower:
Fast flips, noisier regime.
Higher:
More confirmation, later flips.
Channel Padding (chanPad)
Controls how much extra ATR space is added beyond lagMA. Higher padding:
Wider channel, fewer boundary touches.
Lower padding:
Tighter boundary, more reactive “risk edge.”
Max Levels
Controls how many historical flip levels are retained.
Summary
Trend Velocity Channel treats trend as lead-lag separation expressed in ATR units. A fast DEMA tracks the active move, a slower EMA defines baseline value, and their normalized gap (Crush) defines both direction and acceleration strength . That strength drives an adaptive visual language (gradient color, glow width, ribbon depth). The channel itself is directional, with the lead line as the inner edge and a volatility-padded lag boundary as the outer edge, acting as a structural “compromise line.” On every regime flip the script plants a pivot level, tracks retests, and deletes invalidated levels, giving you a clean map of acceleration-based reversal zones.
Pine Script® インジケーター






















