Files
QuanTAlib/lib/volume/vf/vf.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

44 lines
1.3 KiB
Plaintext

// The MIT License (MIT)
// © mihakralj
//@version=6
indicator("Volume Force (VF)", "VF", overlay=false)
//@function Calculates Volume Force, measuring the force of volume behind price movements
//@param len Smoothing period (default: 14)
//@param src Source price for calculation (default: close)
//@param src_vol Volume data (default: volume)
//@returns float The Volume Force value
vf(simple int len, series float src = close, series float src_vol = volume) =>
float price_change = src - nz(src[1], src)
float raw_vf = price_change * nz(src_vol, 0.0)
float alpha = 2.0 / (len + 1)
var bool warmup = true
var float e = 1.0
var float ema_val = 0.0
var float vf_result = raw_vf
ema_val := alpha * (raw_vf - ema_val) + ema_val
if warmup
e *= (1.0 - alpha)
float compensator = 1.0 / (1.0 - e)
vf_result := compensator * ema_val
warmup := e > 1e-10
else
vf_result := ema_val
vf_result
// ---------- Main Calculation ----------
// Parameters
length = input.int(14, "Smoothing Period", minval=1)
// Calculation
vf_line = vf(length, close, volume)
// ---------- Plots ----------
plot(vf_line, "Volume Force", color=color.yellow, linewidth=2)
hline(0, "Zero Line", color.gray, linestyle=hline.style_dashed)
// Color zones for visual clarity
bgcolor(vf_line > 0 ? color.green : color.red)