pub struct Rsi<const N: usize> { /* private fields */ }Expand description
Relative Strength Index over a Wilder period N.
Uses Wilder’s smoothing (alpha = 1 / N). The seed averages the first N
gains and losses; from there each step is the reciprocal-hoisted fused
smoothing avg.mul_add(N - 1, x) / N, identical to wickra_core::Rsi. The
first output appears after N + 1 inputs.
§Example
use wickra_embed_core::{Indicator, Rsi};
let mut rsi = Rsi::<14>::new();
let mut last = None;
for i in 0..40 {
last = rsi.update(100.0 + f64::from(i % 5));
}
assert!(last.is_some());Implementations§
Trait Implementations§
Source§impl<const N: usize> Indicator for Rsi<N>
impl<const N: usize> Indicator for Rsi<N>
Source§fn update(&mut self, input: f64) -> Option<f64>
fn update(&mut self, input: f64) -> Option<f64>
Feed one new data point in and return the freshly computed value, or
None while still warming up.Source§fn reset(&mut self)
fn reset(&mut self)
Reset all internal state, leaving the indicator equivalent to a freshly
constructed instance with the same parameters.
Source§fn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
Number of inputs required before the first non-
None output.Auto Trait Implementations§
impl<const N: usize> Freeze for Rsi<N>
impl<const N: usize> RefUnwindSafe for Rsi<N>
impl<const N: usize> Send for Rsi<N>
impl<const N: usize> Sync for Rsi<N>
impl<const N: usize> Unpin for Rsi<N>
impl<const N: usize> UnsafeUnpin for Rsi<N>
impl<const N: usize> UnwindSafe for Rsi<N>
Blanket Implementations§
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
Mutably borrows from an owned value. Read more