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.
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。