mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-23 21:18:04 +00:00
SIMD Refactor: Merge simd-dev into dev (#55)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat> Co-authored-by: Warp <agent@warp.dev>
This commit is contained in:
co-authored by
Claude Opus 4.5
aider
Warp
parent
5bcdf8d614
commit
86fe32a682
@@ -0,0 +1,26 @@
|
||||
// The MIT License (MIT)
|
||||
// © mihakralj
|
||||
//@version=6
|
||||
indicator("On Balance Volume (OBV)", "OBV", overlay=false)
|
||||
|
||||
//@function Calculates On Balance Volume
|
||||
//@doc https://github.com/mihakralj/pinescript/blob/main/indicators/volume/obv.md
|
||||
//@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)
|
||||
Reference in New Issue
Block a user