OPEN-SOURCE SCRIPT

Volume Weighted Intra Bar Standard Deviation

89
This indicator provides a high-resolution analysis of market volatility by dissecting each bar on the chart into its fundamental components. It uses data from a lower, intra-bar timeframe to separate the total volatility of a single bar into its 'directional' and 'non-directional' parts.

Key Features:

Intra-Bar Volatility Decomposition: For each bar on the chart, the indicator analyzes the underlying price action on a smaller timeframe ('Intra-Bar Timeframe') and quantifies two types of volatility:

Between-Bar Volatility (Directional): Calculated from price movements between the intra-bar candles. This component represents the directional, trending price action within the main bar.

Within-Bar Volatility (Non-Directional): Calculated from price fluctuations inside each intra-bar candle. This component represents the choppy, noisy, or ranging price action.

Dual Display Modes: The indicator offers two modes to visualize this information:

Absolute Mode: Plots the total standard deviation as a stacked column chart, showing the absolute magnitude of volatility and the contribution of each component.

Normalized Mode: Plots the components as a 100% stacked column chart (scaled from 0 to 1), focusing purely on the percentage ratio of 'between-bar' (trending) and 'within-bar' (choppy) volatility.

Calculation Options:

Statistical Model: The 'Estimate Bar Statistics' option (enabled by default) uses a statistical model ('Estimator') to perform the decomposition. (Assumption: In this mode, the Source input is ignored, and an estimated mean for each bar is used instead).

Normalization: An optional 'Normalize Volatility' setting calculates volatility in percentage terms (log-space).

Volume Weighting: An option (Volume weighted) applies volume weighting to all intra-bar volatility calculations.

Volatility Pivot Detection: Includes a built-in pivot detector that identifies significant turning points (highs and lows) in the total volatility line. (Note: This is only visible in 'Absolute Mode').

Note on Confirmation (Lag): Pivot signals are confirmed using a lookback method. A pivot is only plotted after the Pivot Right Bars input has passed, which introduces an inherent lag.

Multi-Timeframe (MTF) Capability:

MTF Analysis Lines: The entire intra-bar analysis can be run on a higher timeframe (using the Timeframe input), with standard options to handle gaps (Fill Gaps) and prevent repainting (Wait for...).

Limitation: The Pivot detection (Calculate Pivots) is disabled if a Higher Timeframe (HTF) is selected.

Integrated Alerts: Includes 6 alerts for:

Volatility character changes (e.g., 'Character Change from Choppy to Trend').

Dominant character emerging (e.g., 'Trend Character Emerging').

Total Volatility pivot (High/Low) detection.

Caution: Real-Time Data Behavior (Intra-Bar Repainting) This indicator uses high-resolution intra-bar data. As a result, the values on the current, unclosed bar (the real-time bar) will update dynamically as new intra-bar data arrives. This behavior is normal and necessary for this type of analysis. Signals should only be considered final after the main chart bar has closed.

DISCLAIMER

For Informational/Educational Use Only: This indicator is provided for informational and educational purposes only. It does not constitute financial, investment, or trading advice, nor is it a recommendation to buy or sell any asset.

Use at Your Own Risk: All trading decisions you make based on the information or signals generated by this indicator are made solely at your own risk.

No Guarantee of Performance: Past performance is not an indicator of future results. The author makes no guarantee regarding the accuracy of the signals or future profitability.

No Liability: The author shall not be held liable for any financial losses or damages incurred directly or indirectly from the use of this indicator.

Signals Are Not Recommendations: The alerts and visual signals (e.g., crossovers) generated by this tool are not direct recommendations to buy or sell. They are technical observations for your own analysis and consideration.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.