mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-06 04:57:44 +00:00
24e86d762a
- 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.
26 lines
797 B
Plaintext
26 lines
797 B
Plaintext
// The MIT License (MIT)
|
|
// © mihakralj
|
|
//@version=6
|
|
indicator("On Balance Volume (OBV)", "OBV", overlay=false)
|
|
|
|
//@function Calculates On Balance Volume
|
|
//@param c Close price series
|
|
//@param vol Volume series
|
|
//@returns Cumulative On Balance Volume value
|
|
//@optimized for performance and dirty data
|
|
obv(series float c = close, series float vol = volume) =>
|
|
float close_price = nz(c, close)
|
|
float volume_val = nz(vol, 0.0)
|
|
float prev_close = nz(close_price[1], close_price)
|
|
var float obv_cumulative = 0.0
|
|
obv_cumulative += close_price > prev_close ? volume_val : close_price < prev_close ? -volume_val : 0.0
|
|
obv_cumulative
|
|
|
|
// ---------- Main loop ----------
|
|
|
|
// Calculation
|
|
obv_value = obv(close, volume)
|
|
|
|
// Plot
|
|
plot(obv_value, "OBV", color=color.yellow, linewidth=2)
|