OPEN-SOURCE SCRIPT
Relative Volatility Mass [SciQua]

The ⚖️ Relative Volatility Mass (RVM) is a volatility-based tool inspired by the Relative Volatility Index (RVI).
While the RVI measures the ratio of upward to downward volatility over a period, RVM takes a different approach:
This makes RVM particularly useful for identifying sustained high-volatility conditions without being diluted by averaging.
────────────────────────────────────────────────────────────
╭────────────╮
How It Works
╰────────────╯
1. Standard Deviation Calculation
• Computes the standard deviation of the chosen `Source` over a `Standard Deviation Length` (`stdDevLen`).
2. Directional Separation
• Volatility on up bars (`chg > 0`) is treated as upward volatility.
• Volatility on down bars (`chg < 0`) is treated as downward volatility.
3. Rolling Sum
• Over a `Sum Length` (`sumLen`), the upward and downward volatilities are summed separately using `math.sum()`.
4. Relative Volatility Mass
• The two sums are added together to get the total volatility mass for the rolling window.
Formula:
RVM = Σ(σup) + Σ(σdown)
where σ is the standard deviation over `stdDevLen`.
╭────────────╮
Key Features
╰────────────╯
╭─────╮
Usage
╰─────╯
RVM is not bounded like the RVI, so absolute values depend on market volatility and chosen parameters.
Consider normalizing or using smoothing for easier visual comparison.
╭────────────────╮
Example Settings
╰────────────────╯
╭───────────────────╮
Notes & Limitations
╰───────────────────╯
╭───────╮
Credits
╰───────╯
While the RVI measures the ratio of upward to downward volatility over a period, RVM takes a different approach:
- It sums the standard deviation of price changes over a rolling window, separating upward volatility from downward volatility.
- The result is a measure of the total “volatility mass” over a user-defined period, rather than an average or normalized ratio.
This makes RVM particularly useful for identifying sustained high-volatility conditions without being diluted by averaging.
────────────────────────────────────────────────────────────
╭────────────╮
How It Works
╰────────────╯
1. Standard Deviation Calculation
• Computes the standard deviation of the chosen `Source` over a `Standard Deviation Length` (`stdDevLen`).
2. Directional Separation
• Volatility on up bars (`chg > 0`) is treated as upward volatility.
• Volatility on down bars (`chg < 0`) is treated as downward volatility.
3. Rolling Sum
• Over a `Sum Length` (`sumLen`), the upward and downward volatilities are summed separately using `math.sum()`.
4. Relative Volatility Mass
• The two sums are added together to get the total volatility mass for the rolling window.
Formula:
RVM = Σ(σup) + Σ(σdown)
where σ is the standard deviation over `stdDevLen`.
╭────────────╮
Key Features
╰────────────╯
- Directional Volatility Tracking – Differentiates between volatility during price advances vs. declines.
- Rolling Volatility Mass – Shows the total standard deviation accumulation over a given period.
- Optional Smoothing – Multiple MA types, including SMA, EMA, SMMA (RMA), WMA, VWMA.
- Bollinger Band Overlay – Available when SMA is selected, with adjustable standard deviation multiplier.
- Configurable Source – Apply RVM to `close`, `open`, `hl2`, or any custom source.
╭─────╮
Usage
╰─────╯
- Trend Confirmation: High RVM values can confirm strong trending conditions.
- Breakout Detection: Spikes in RVM often precede or accompany price breakouts.
- Volatility Cycle Analysis: Compare periods of contraction and expansion.
RVM is not bounded like the RVI, so absolute values depend on market volatility and chosen parameters.
Consider normalizing or using smoothing for easier visual comparison.
╭────────────────╮
Example Settings
╰────────────────╯
- Short-term volatility detection: `stdDevLen = 5`, `sumLen = 10`
- Medium-term trend volatility: `stdDevLen = 14`, `sumLen = 20`
- Enable `SMA + Bollinger Bands` to visualize when volatility is unusually high or low relative to recent history.
╭───────────────────╮
Notes & Limitations
╰───────────────────╯
- Not a directional signal by itself — use alongside price structure, volume, or other indicators.
- Higher `sumLen` will smooth short-term fluctuations but reduce responsiveness.
- Because it sums, not averages, values will scale with both volatility and chosen window size.
╭───────╮
Credits
╰───────╯
- Based on the Relative Volatility Index concept by Donald Dorsey (1993).
- TradingView
- SciQua - Joshua Danford
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
🚀 Founder of SciQua | Strategy. Simulation. Signals.
TradingView indicators, backtesting tools, weekly contests, and live market analysis.
Join free, compete, win, and stay updated at sciqua.com
TradingView indicators, backtesting tools, weekly contests, and live market analysis.
Join free, compete, win, and stay updated at sciqua.com
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
🚀 Founder of SciQua | Strategy. Simulation. Signals.
TradingView indicators, backtesting tools, weekly contests, and live market analysis.
Join free, compete, win, and stay updated at sciqua.com
TradingView indicators, backtesting tools, weekly contests, and live market analysis.
Join free, compete, win, and stay updated at sciqua.com
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.