[−][src]Struct ta::indicators::OnBalanceVolume
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
Methods
impl OnBalanceVolume
[src]
Trait Implementations
impl Clone for OnBalanceVolume
[src]
fn clone(&self) -> OnBalanceVolume
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for OnBalanceVolume
[src]
impl Default for OnBalanceVolume
[src]
impl Display for OnBalanceVolume
[src]
impl<'a, T: Close + Volume> Next<&'a T> for OnBalanceVolume
[src]
impl Reset for OnBalanceVolume
[src]
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,