Files
QuanTAlib/lib/volume/vroc/vroc.pine
T
Miha Kralj 24e86d762a Add documentation links for various volatility indicators and channels
- Updated BBWN, BBWP, CCV, CV, CVI, EWMA, GKV, HLV, HV, Jvolty, JVOLTYN, MASSI, NATR, RSV, RV, RVI, TR, UI, VOV, VR, YZV indicators with documentation links.
- Added documentation links for Aberration, Acceleration Bands, Andrews' Pitchfork, Adaptive Price Zone, ATR Bands, Bollinger Bands, Center of Gravity, Donchian Channels, Decay Min-Max Channel, Detrended Synthetic Price, EACP, EBSW, HOMOD, Jurik Volatility Bands, Keltner Channel, MA Envelope, Min-Max Channel, Price Channel, Regression Channels, Standard Deviation Channel, Stoller Average Range Channel, Super Trend Bands, Ultimate Bands, Ultimate Channel, VWAP Bands, and VWAP with Standard Deviation Bands.
2026-02-18 11:55:48 -08:00

37 lines
1.3 KiB
Plaintext

// The MIT License (MIT)
// © mihakralj
//@version=6
indicator("Volume Rate of Change (VROC)", "VROC", overlay=false)
//@function Calculates Volume Rate of Change
//@param vol Volume series for rate of change calculation
//@param period Number of periods for comparison
//@param calc_type Calculation type: true for percentage, false for point change
//@returns Volume Rate of Change value
//@optimized for performance and dirty data
vroc(simple int period, simple bool calc_type, series float vol = volume) =>
if period <= 0
runtime.error("Period must be greater than 0")
float current_volume = vol
float historical_volume = vol[period]
if na(current_volume) or na(historical_volume)
na
else if calc_type
historical_volume != 0.0 ? ((current_volume - historical_volume) / historical_volume) * 100.0 : na
else
current_volume - historical_volume
// ---------- Main loop ----------
// Inputs
i_period = input.int(12, "Period", minval=1, tooltip="Number of periods for comparison")
i_calc_type = input.string("Point", "Calculation Type", options=["Point", "Percent"], tooltip="Point or Percent calculation")
// Calculation
is_percent = i_calc_type == "Percent"
vroc_value = vroc(i_period, is_percent)
// Plot
plot(vroc_value, "VROC", color=color.yellow, linewidth=2)