pub struct Pmo { /* private fields */ }Expand description
Price Momentum Oscillator — Carl Swenlin’s DecisionPoint PMO line.
PMO is a doubly-smoothed rate of change. The 1-bar percentage change is
smoothed once, scaled by 10, then smoothed again:
roc_t = (price_t / price_{t−1} − 1) · 100
smoothed_t = customEMA(roc, smoothing1)_t
PMO_t = customEMA(10 · smoothed, smoothing2)_tcustomEMA is the DecisionPoint smoothing: an exponential average whose
smoothing constant is 2 / period (not the textbook 2 / (period + 1)),
seeded from the very first value. The conventional periods are 35 and
20. The classic PMO signal line is simply a 10-period EMA of this
PMO line — compose it with Chain and an Ema if you
need it.
§Example
use wickra_core::{Indicator, Pmo};
let mut indicator = Pmo::new(35, 20).unwrap();
let mut last = None;
for i in 0..120 {
last = indicator.update(100.0 + f64::from(i));
}
assert!(last.is_some());Implementations§
Trait Implementations§
Source§impl Indicator for Pmo
impl Indicator for Pmo
Source§fn update(&mut self, input: f64) -> Option<f64>
fn update(&mut self, input: f64) -> Option<f64>
Feed one new data point into the indicator and return the freshly computed
output, or
None if the indicator is 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 can be produced.Auto Trait Implementations§
impl Freeze for Pmo
impl RefUnwindSafe for Pmo
impl Send for Pmo
impl Sync for Pmo
impl Unpin for Pmo
impl UnsafeUnpin for Pmo
impl UnwindSafe for Pmo
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>>
Run the indicator over a slice of inputs in order, returning one output (or
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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