pub struct HighLowIndex { /* private fields */ }Expand description
High-Low Index — a simple moving average of the record high percent,
100 * new_highs / (new_highs + new_lows).
The record high percent is the share of new-extreme issues that are new highs rather than new lows; smoothing it over a window (the classic period is 10) gives the High-Low Index. Readings above 50 mean new highs dominate (a healthy, broadening trend), readings below 50 mean new lows dominate. The 30 and 70 lines are watched as oversold / overbought breadth thresholds.
Each tick floors the new-extreme count to one, so a tick with no new highs or
lows contributes a defined 0.0 instead of dividing by zero. The reading is
None until period ticks have been seen.
Input = CrossSection, Output = f64 (a percentage in 0..=100),
warmup_period == period.
§Example
use wickra_core::{CrossSection, HighLowIndex, Indicator, Member};
let mut hli = HighLowIndex::new(2).unwrap();
let highs = CrossSection::new(vec![Member::new(1.0, 1.0, true, false)], 0).unwrap();
assert_eq!(hli.update(highs.clone()), None); // warming up
assert_eq!(hli.update(highs), Some(100.0)); // all new highsImplementations§
Trait Implementations§
Source§impl Clone for HighLowIndex
impl Clone for HighLowIndex
Source§fn clone(&self) -> HighLowIndex
fn clone(&self) -> HighLowIndex
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 HighLowIndex
impl Debug for HighLowIndex
Source§impl Indicator for HighLowIndex
impl Indicator for HighLowIndex
Source§type Input = CrossSection
type Input = CrossSection
f64 for a price, or Candle / Tick).Source§fn update(&mut self, section: CrossSection) -> Option<f64>
fn update(&mut self, section: CrossSection) -> 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 HighLowIndex
impl RefUnwindSafe for HighLowIndex
impl Send for HighLowIndex
impl Sync for HighLowIndex
impl Unpin for HighLowIndex
impl UnsafeUnpin for HighLowIndex
impl UnwindSafe for HighLowIndex
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