Struct ta::indicators::OnBalanceVolume [−][src]
pub struct OnBalanceVolume { /* fields omitted */ }
Expand description
On Balance Volume (OBV).
The OBV is an volume and price based oscillator which gives cumulative total volumes. OBV measures buying and selling pressure as a cumulative indicator, adding volume on up days and subtracting it on down days.
Formula
If the closing price is above the prior close price then: Current OBV = Previous OBV + Current Volume
If the closing price is below the prior close price then: Current OBV = Previous OBV - Current Volume
If the closing prices equals the prior close price then: Current OBV = Previous OBV
Where:
obv - on the balance volume
Example
use ta::indicators::OnBalanceVolume; use ta::{Next, DataItem}; let mut obv = OnBalanceVolume::new(); let di1 = DataItem::builder() .high(3.0) .low(1.0) .close(2.0) .open(1.5) .volume(1000.0) .build().unwrap(); let di2 = DataItem::builder() .high(3.0) .low(1.0) .close(1.5) .open(1.5) .volume(300.0) .build().unwrap(); assert_eq!(obv.next(&di1), 1000.0); assert_eq!(obv.next(&di2), 700.0);
Links
Implementations
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for OnBalanceVolume
impl Send for OnBalanceVolume
impl Sync for OnBalanceVolume
impl Unpin for OnBalanceVolume
impl UnwindSafe for OnBalanceVolume
Blanket Implementations
Mutably borrows from an owned value. Read more