OPEN-SOURCE SCRIPT
Diupdate Nasan Stretch - Velocity Quadrant Plot

# Stretch/Velocity Quadrant Plot
The **Stretch/Velocity Quadrant Plot** is a multi-asset market regime and momentum tool designed to track up to **11 symbols simultaneously**.
By plotting **Velocity** against **Stretch**, the indicator shows where each asset sits within the lifecycle of a trend and how it is moving between expansion, exhaustion, reversal, and recovery phases.
It is especially useful for:
* comparing several stocks on one chart,
* identifying leadership and rotation,
* spotting early momentum changes,
* distinguishing strong trends from overextended moves,
* and evaluating how likely a stock is to remain in or leave its current market phase.
## Core Concept
The model combines short-, medium-, and long-term behavior using:
* 13-period EMA
* 21-period EMA
* 34-period EMA
The three horizons are blended using customizable weights.
All values are normalized by ATR, allowing stocks with very different prices and volatility levels to be compared on the same scale.
## Velocity — X-Axis
Velocity measures the rate of change of the three EMAs.
Each EMA uses a separate lookback:
* EMA 13 velocity over 8 bars
* EMA 21 velocity over 13 bars
* EMA 34 velocity over 21 bars
The result represents the speed and direction of the underlying trend.
* Positive Velocity: trend momentum is improving
* Negative Velocity: trend momentum is weakening
## Stretch — Y-Axis
Stretch measures how far price has moved away from its EMA structure.
It is calculated as the ATR-normalized distance between price and the 13-, 21-, and 34-period EMAs.
* Positive Stretch: price is trading above its trend structure
* Negative Stretch: price is trading below its trend structure
* Larger absolute values: price is farther from equilibrium
## The Four Market Quadrants
### Q1 — Bullish Expansion
**Positive Velocity / Positive Stretch**
The asset is above its trend structure and momentum is accelerating.
This is typically associated with:
* strong uptrends,
* momentum continuation,
* leadership,
* and expanding price strength.
A stock moving from Q4 into Q1 may represent a developing recovery turning into a confirmed expansion phase.
### Q2 — Bearish Reversion
**Negative Velocity / Positive Stretch**
Price remains above its trend structure, but momentum is weakening.
This can indicate:
* an aging uptrend,
* loss of momentum,
* consolidation,
* profit-taking,
* or the beginning of a pullback.
Stocks that are highly stretched in Q1 and begin rotating into Q2 may be entering an exhaustion phase.
### Q3 — Bearish Expansion
**Negative Velocity / Negative Stretch**
Price is below its trend structure and downside momentum is increasing.
This is typically associated with:
* established downtrends,
* accelerating weakness,
* distribution,
* and bearish continuation.
### Q4 — Bullish Reversion
**Positive Velocity / Negative Stretch**
Price remains below its trend structure, but momentum has turned positive.
This can signal:
* improving conditions,
* mean reversion,
* early recovery,
* or a potential transition back into bullish expansion.
A rotation from Q4 into Q1 is one of the most important bullish transitions on the chart.
## Multi-Asset Tracking
The indicator supports up to **11 editable symbols**.
Each asset is displayed with:
* its own color,
* a historical trail,
* a current-position marker,
* and an automatically generated ticker label.
This makes it easy to compare:
* relative trend strength,
* market rotation,
* momentum leadership,
* and differences in trend maturity.
## Trailing Paths
Each ticker includes a configurable historical trail.
The trail shows how the asset arrived at its current position and whether it is:
* accelerating,
* slowing,
* rotating,
* reversing,
* or moving sideways near a quadrant boundary.
The direction of the trail is often as important as the current quadrant.
## True Range Variability Clouds
Optional ribbons are drawn around each asset’s trail using:
[
\frac{\text{Standard Deviation of True Range}}
{\text{Average True Range}}
]
The calculation is blended over the same 8-, 13-, and 21-bar horizons used by the Velocity model.
Cloud thickness changes at every point along the trail:
* Narrow cloud: volatility is stable and movement is more orderly
* Wide cloud: volatility is inconsistent, noisy, or unstable
This provides an additional layer of information beyond direction and momentum.
The center trail shows where the asset is moving.
The surrounding cloud shows how reliable or disorderly that movement has been.
## Position-Sensitive Quadrant Statistics
A dedicated statistics table can be assigned to one requested ticker.
The table displays:
* current quadrant,
* current uninterrupted stay,
* average historical duration in each quadrant,
* number of completed quadrant runs,
* current Velocity and Stretch values,
* and transition probabilities over several forward horizons.
The transition model does not rely only on the quadrant name.
Each quadrant is divided into a 3 × 3 internal grid based on:
* Velocity magnitude: Low, Medium, or High
* Stretch magnitude: Low, Medium, or High
This creates 36 possible origin states:
[
4\text{ quadrants}
\times
3\text{ Velocity bins}
\times
3\text{ Stretch bins}
=====================
36\text{ states}
]
The model therefore estimates probabilities such as:
> From Q1 with High Velocity and Medium Stretch, what is the probability of being in Q1, Q2, Q3, or Q4 after 5, 10, 15, or 21 bars?
This provides a more detailed transition model than treating every point inside the same quadrant as identical.
## Customizable Smoothing
The Velocity, Stretch, and cloud calculations can be smoothed using:
* EMA
* RMA
* SMA
* WMA
* or no smoothing
An optional second smoothing pass is also available for users who prefer slower, cleaner trails.
## How to Use the Indicator
The indicator is best used to evaluate trend rotation rather than as a standalone buy or sell signal.
Examples:
* Multiple stocks rotating from Q4 into Q1 may indicate broad market recovery.
* A leader remaining in Q1 with a narrow cloud may indicate persistent, orderly momentum.
* A highly stretched stock in Q1 rotating toward Q2 may be losing momentum.
* A stock in Q4 with rising Velocity may be developing an early recovery setup.
* A widening cloud may warn that the apparent move is becoming less stable.
* A stock near a quadrant boundary may be more likely to switch states than one deep inside a quadrant.
The strongest interpretation comes from combining:
* current quadrant,
* trail direction,
* cloud width,
* distance from the quadrant boundaries,
* and the transition-probability table.
## Important Note
This indicator is intended as a visual and statistical market-analysis tool.
It does not predict future prices with certainty and should be used together with:
* trend confirmation,
* volume,
* support and resistance,
* fundamentals,
* earnings risk,
* and position-sizing rules.
The **Stretch/Velocity Quadrant Plot** is a multi-asset market regime and momentum tool designed to track up to **11 symbols simultaneously**.
By plotting **Velocity** against **Stretch**, the indicator shows where each asset sits within the lifecycle of a trend and how it is moving between expansion, exhaustion, reversal, and recovery phases.
It is especially useful for:
* comparing several stocks on one chart,
* identifying leadership and rotation,
* spotting early momentum changes,
* distinguishing strong trends from overextended moves,
* and evaluating how likely a stock is to remain in or leave its current market phase.
## Core Concept
The model combines short-, medium-, and long-term behavior using:
* 13-period EMA
* 21-period EMA
* 34-period EMA
The three horizons are blended using customizable weights.
All values are normalized by ATR, allowing stocks with very different prices and volatility levels to be compared on the same scale.
## Velocity — X-Axis
Velocity measures the rate of change of the three EMAs.
Each EMA uses a separate lookback:
* EMA 13 velocity over 8 bars
* EMA 21 velocity over 13 bars
* EMA 34 velocity over 21 bars
The result represents the speed and direction of the underlying trend.
* Positive Velocity: trend momentum is improving
* Negative Velocity: trend momentum is weakening
## Stretch — Y-Axis
Stretch measures how far price has moved away from its EMA structure.
It is calculated as the ATR-normalized distance between price and the 13-, 21-, and 34-period EMAs.
* Positive Stretch: price is trading above its trend structure
* Negative Stretch: price is trading below its trend structure
* Larger absolute values: price is farther from equilibrium
## The Four Market Quadrants
### Q1 — Bullish Expansion
**Positive Velocity / Positive Stretch**
The asset is above its trend structure and momentum is accelerating.
This is typically associated with:
* strong uptrends,
* momentum continuation,
* leadership,
* and expanding price strength.
A stock moving from Q4 into Q1 may represent a developing recovery turning into a confirmed expansion phase.
### Q2 — Bearish Reversion
**Negative Velocity / Positive Stretch**
Price remains above its trend structure, but momentum is weakening.
This can indicate:
* an aging uptrend,
* loss of momentum,
* consolidation,
* profit-taking,
* or the beginning of a pullback.
Stocks that are highly stretched in Q1 and begin rotating into Q2 may be entering an exhaustion phase.
### Q3 — Bearish Expansion
**Negative Velocity / Negative Stretch**
Price is below its trend structure and downside momentum is increasing.
This is typically associated with:
* established downtrends,
* accelerating weakness,
* distribution,
* and bearish continuation.
### Q4 — Bullish Reversion
**Positive Velocity / Negative Stretch**
Price remains below its trend structure, but momentum has turned positive.
This can signal:
* improving conditions,
* mean reversion,
* early recovery,
* or a potential transition back into bullish expansion.
A rotation from Q4 into Q1 is one of the most important bullish transitions on the chart.
## Multi-Asset Tracking
The indicator supports up to **11 editable symbols**.
Each asset is displayed with:
* its own color,
* a historical trail,
* a current-position marker,
* and an automatically generated ticker label.
This makes it easy to compare:
* relative trend strength,
* market rotation,
* momentum leadership,
* and differences in trend maturity.
## Trailing Paths
Each ticker includes a configurable historical trail.
The trail shows how the asset arrived at its current position and whether it is:
* accelerating,
* slowing,
* rotating,
* reversing,
* or moving sideways near a quadrant boundary.
The direction of the trail is often as important as the current quadrant.
## True Range Variability Clouds
Optional ribbons are drawn around each asset’s trail using:
[
\frac{\text{Standard Deviation of True Range}}
{\text{Average True Range}}
]
The calculation is blended over the same 8-, 13-, and 21-bar horizons used by the Velocity model.
Cloud thickness changes at every point along the trail:
* Narrow cloud: volatility is stable and movement is more orderly
* Wide cloud: volatility is inconsistent, noisy, or unstable
This provides an additional layer of information beyond direction and momentum.
The center trail shows where the asset is moving.
The surrounding cloud shows how reliable or disorderly that movement has been.
## Position-Sensitive Quadrant Statistics
A dedicated statistics table can be assigned to one requested ticker.
The table displays:
* current quadrant,
* current uninterrupted stay,
* average historical duration in each quadrant,
* number of completed quadrant runs,
* current Velocity and Stretch values,
* and transition probabilities over several forward horizons.
The transition model does not rely only on the quadrant name.
Each quadrant is divided into a 3 × 3 internal grid based on:
* Velocity magnitude: Low, Medium, or High
* Stretch magnitude: Low, Medium, or High
This creates 36 possible origin states:
[
4\text{ quadrants}
\times
3\text{ Velocity bins}
\times
3\text{ Stretch bins}
=====================
36\text{ states}
]
The model therefore estimates probabilities such as:
> From Q1 with High Velocity and Medium Stretch, what is the probability of being in Q1, Q2, Q3, or Q4 after 5, 10, 15, or 21 bars?
This provides a more detailed transition model than treating every point inside the same quadrant as identical.
## Customizable Smoothing
The Velocity, Stretch, and cloud calculations can be smoothed using:
* EMA
* RMA
* SMA
* WMA
* or no smoothing
An optional second smoothing pass is also available for users who prefer slower, cleaner trails.
## How to Use the Indicator
The indicator is best used to evaluate trend rotation rather than as a standalone buy or sell signal.
Examples:
* Multiple stocks rotating from Q4 into Q1 may indicate broad market recovery.
* A leader remaining in Q1 with a narrow cloud may indicate persistent, orderly momentum.
* A highly stretched stock in Q1 rotating toward Q2 may be losing momentum.
* A stock in Q4 with rising Velocity may be developing an early recovery setup.
* A widening cloud may warn that the apparent move is becoming less stable.
* A stock near a quadrant boundary may be more likely to switch states than one deep inside a quadrant.
The strongest interpretation comes from combining:
* current quadrant,
* trail direction,
* cloud width,
* distance from the quadrant boundaries,
* and the transition-probability table.
## Important Note
This indicator is intended as a visual and statistical market-analysis tool.
It does not predict future prices with certainty and should be used together with:
* trend confirmation,
* volume,
* support and resistance,
* fundamentals,
* earnings risk,
* and position-sizing rules.
Catatan Rilis
The indicator has evolved from a historical trail and quadrant-statistics tool into a forward state-projection model. For the selected ticker, it tracks a 2D phase space built from EMA velocity on the X-axis and ATR-normalized price stretch on the Y-axis. The projected path is generated using physics-style motion: current velocity and acceleration are carried forward with dynamically estimated persistence, while decaying buy/sell pressure acts as an external force that can bend, rotate, or reverse the trajectory. A confidence band widens or narrows based on residual error, direction quality, acceleration stability, boundary proximity, and historical quadrant survival.The 13-, 21-, and 34-length components are projected separately, each with its own velocity persistence, acceleration persistence, and pressure response. Their projected EMA and stretch values are converted back into implied prices, then blended using 25% / 50% / 25% weights. The endpoint shows the blended projected price, expected percentage change, individual P13/P21/P34 estimates, and a model-dispersion range showing how much the three component forecasts disagree.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.