OPEN-SOURCE SCRIPT
VWAP slope (normalized)

**Normalized VWAP Slope (Session-Based Regime Filter)**
This indicator measures the slope of the session VWAP using a linear regression model and normalizes it by ATR. The goal is to identify whether the market is in a **balanced (range) state** or in a **directional (trend / discovery) state**.
The script calculates the slope of the VWAP regression line over a configurable lookback period and divides it by the current ATR value. This normalization makes the slope comparable across different instruments and volatility environments.
To avoid unstable readings at the start of a session, the indicator includes a **warm-up filter** that ignores the first N bars after the daily session reset.
**How it works**
1. Session VWAP is calculated using TradingView's built-in VWAP function.
2. A linear regression is applied to the VWAP over the selected lookback length.
3. The difference between consecutive regression values produces the VWAP slope.
4. The slope is normalized by ATR to account for changing volatility.
5. During the warm-up period after the session reset, values are suppressed to prevent distortions caused by the VWAP initialization.
**Interpretation**
The normalized slope represents how steep the VWAP is relative to normal market volatility.
Typical interpretation:
* Values near **0** → VWAP is flat → market is likely in **balance / range**
* Moderate positive or negative values → **developing directional bias**
* Large absolute values → **strong directional move / information driven market**
**Typical threshold usage**
Many mean-reversion strategies use thresholds to determine when range trading is allowed.
Example guideline:
For Intraday Session
* `|slope| < 0.01`and |slope| > -0.01 → Balanced market
* `|slope| > 0.01`or |slope| < -0.01 → Directional market (range trading discouraged)
These thresholds should be adjusted depending on the instrument and timeframe.
**Inputs**
* **LinReg Length** – Lookback period used for the VWAP regression slope.
* **Warm-up Bars** – Number of bars ignored after a new session begins.
* **ATR Length** – Period used for volatility normalization.
* **Upper / Lower Threshold** – Reference levels used to identify balanced vs directional conditions.
**Purpose**
This tool is designed primarily as a **market regime filter**, especially useful for strategies that rely on mean reversion around VWAP. By detecting when the VWAP becomes steep relative to normal volatility, traders can avoid applying range strategies during strong directional moves.
This indicator measures the slope of the session VWAP using a linear regression model and normalizes it by ATR. The goal is to identify whether the market is in a **balanced (range) state** or in a **directional (trend / discovery) state**.
The script calculates the slope of the VWAP regression line over a configurable lookback period and divides it by the current ATR value. This normalization makes the slope comparable across different instruments and volatility environments.
To avoid unstable readings at the start of a session, the indicator includes a **warm-up filter** that ignores the first N bars after the daily session reset.
**How it works**
1. Session VWAP is calculated using TradingView's built-in VWAP function.
2. A linear regression is applied to the VWAP over the selected lookback length.
3. The difference between consecutive regression values produces the VWAP slope.
4. The slope is normalized by ATR to account for changing volatility.
5. During the warm-up period after the session reset, values are suppressed to prevent distortions caused by the VWAP initialization.
**Interpretation**
The normalized slope represents how steep the VWAP is relative to normal market volatility.
Typical interpretation:
* Values near **0** → VWAP is flat → market is likely in **balance / range**
* Moderate positive or negative values → **developing directional bias**
* Large absolute values → **strong directional move / information driven market**
**Typical threshold usage**
Many mean-reversion strategies use thresholds to determine when range trading is allowed.
Example guideline:
For Intraday Session
* `|slope| < 0.01`and |slope| > -0.01 → Balanced market
* `|slope| > 0.01`or |slope| < -0.01 → Directional market (range trading discouraged)
These thresholds should be adjusted depending on the instrument and timeframe.
**Inputs**
* **LinReg Length** – Lookback period used for the VWAP regression slope.
* **Warm-up Bars** – Number of bars ignored after a new session begins.
* **ATR Length** – Period used for volatility normalization.
* **Upper / Lower Threshold** – Reference levels used to identify balanced vs directional conditions.
**Purpose**
This tool is designed primarily as a **market regime filter**, especially useful for strategies that rely on mean reversion around VWAP. By detecting when the VWAP becomes steep relative to normal volatility, traders can avoid applying range strategies during strong directional moves.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.