pub struct BetterVolume { /* private fields */ }Expand description
Better Volume — a Volume-Spread-Analysis (VSA) “effort versus result” oscillator: how much volume (effort) a bar spent relative to the price range (result) it achieved, both normalised against their own recent averages.
range_t = high_t − low_t
rel_vol = volume_t / SMA(volume, period)
rel_range = range_t / SMA(range, period)
BetterVol = rel_vol − rel_rangeVolume-Spread Analysis (Wyckoff, popularised by Tom Williams) reads markets
through the relationship between effort (volume) and result (the bar’s
spread). A bar with heavy volume but a narrow range — rel_vol high while
rel_range low, so the oscillator is positive — is churn: large effort
produced little movement, the hallmark of absorption (supply meeting demand at
a top, or vice versa at a bottom). A bar that travels far on light volume —
negative oscillator — shows ease of movement, a trend meeting no resistance.
Both legs are normalised by their period simple moving averages (including
the current bar), so the output is centred near 0 and self-scales to the
instrument. A degenerate average of 0 makes its leg 0 rather than dividing
by zero. The first value lands after period inputs. Each update is O(1).
§Example
use wickra_core::{Candle, Indicator, BetterVolume};
let mut indicator = BetterVolume::new(20).unwrap();
let mut last = None;
for i in 0..60 {
let base = 100.0 + f64::from(i);
let c = Candle::new(base, base + 2.0, base - 2.0, base + 0.5, 1_000.0, 0).unwrap();
last = indicator.update(c);
}
assert!(last.is_some());Implementations§
Source§impl BetterVolume
impl BetterVolume
Trait Implementations§
Source§impl Clone for BetterVolume
impl Clone for BetterVolume
Source§fn clone(&self) -> BetterVolume
fn clone(&self) -> BetterVolume
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BetterVolume
impl Debug for BetterVolume
Source§impl Indicator for BetterVolume
impl Indicator for BetterVolume
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 BetterVolume
impl RefUnwindSafe for BetterVolume
impl Send for BetterVolume
impl Sync for BetterVolume
impl Unpin for BetterVolume
impl UnsafeUnpin for BetterVolume
impl UnwindSafe for BetterVolume
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