pub struct Kvo { /* private fields */ }Expand description
Stephen J. Klinger’s Volume Oscillator — a long/short-term volume-force MACD with trend-aware cumulative-money-flow weighting.
Each bar produces a “volume force” (vf) whose sign tracks the daily trend
(+1 on an up day, −1 on a down day, carry-over otherwise) and whose
magnitude scales with how the current accumulation horizon compares to the
previous trend’s. The KVO line is the difference of two EMAs of vf:
dm_t = high_t + low_t + close_t (the "daily measurement")
trend = sign(dm_t − dm_{t−1}) if differs from previous trend, reset cm
cm_t = cm_{t−1} + dm_t if trend unchanged
cm_t = dm_{t−1} + dm_t if trend just flipped
vf_t = volume_t · |2·(dm_t/cm_t − 1)| · trend · 100
KVO_t = EMA(vf, fast)_t − EMA(vf, slow)_tKlinger’s textbook configuration is fast = 34, slow = 55 on daily bars.
The first bar only seeds dm_{t−1}, so the very first vf lands at bar 2;
the slow EMA then needs slow raw vf values to seed, putting the first
KVO emission at bar slow + 1. A zero cm_t (which only happens on the
trend-flip branch when both the prior and current dm are zero) collapses
vf to 0.
§Example
use wickra_core::{Candle, Indicator, Kvo};
let mut indicator = Kvo::new(34, 55).unwrap();
let mut last = None;
for i in 0..120 {
let base = 100.0 + f64::from(i);
let candle =
Candle::new(base, base + 2.0, base - 2.0, base + 1.0, 10.0, i64::from(i)).unwrap();
last = indicator.update(candle);
}
assert!(last.is_some());Implementations§
Trait Implementations§
Source§impl Indicator for Kvo
impl Indicator for Kvo
Source§type Input = Candle
type Input = Candle
f64 for a price, or Candle / Tick).Source§fn update(&mut self, candle: Candle) -> Option<f64>
fn update(&mut self, candle: Candle) -> Option<f64>
None if the indicator is still warming up.Source§fn reset(&mut self)
fn reset(&mut self)
Source§fn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
None output can be produced.Auto Trait Implementations§
impl Freeze for Kvo
impl RefUnwindSafe for Kvo
impl Send for Kvo
impl Sync for Kvo
impl Unpin for Kvo
impl UnsafeUnpin for Kvo
impl UnwindSafe for Kvo
Blanket Implementations§
Source§impl<T> BatchExt for Twhere
T: Indicator,
impl<T> BatchExt for Twhere
T: Indicator,
Source§fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
None during warmup) per input.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more