pub struct LsmaEngine { /* private fields */ }Expand description
Least Squares Moving Average: the endpoint of an ordinary least-squares fit through the last
period closes.
The fit runs over the local window index x = 0 ..= period - 1, so value is the fitted
price at x = period - 1 — the current bar, never beyond it.
The same fit already carries more than that endpoint, and those numbers are published rather than recomputed by callers:
extra["slope"]: price change per bar of the fitted line, in price units per bar. Not an angle: a slope drawn as an angle depends on the axis scaling of whoever draws it.extra["intercept"]: fitted price at the local window index 0, i.e. at the oldest bar of the current window — not at the start of the series.extra["r2"]: share of the window’s price variance explained by the line, in0..=1. A goodness of fit, not a probability that the move continues. A window without price variance has nothing left to explain; the convention here is1.
First output: with the period-th bar, and only when the fit is defined (a window of
non-finite values yields none). Indicator::reset clears the window, so the next series
starts deterministically.
Implementations§
Trait Implementations§
Source§impl Clone for LsmaEngine
impl Clone for LsmaEngine
Source§fn clone(&self) -> LsmaEngine
fn clone(&self) -> LsmaEngine
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LsmaEngine
impl Debug for LsmaEngine
Source§impl Indicator for LsmaEngine
impl Indicator for LsmaEngine
fn name(&self) -> &str
fn warmup_period(&self) -> usize
fn reset(&mut self)
fn on_bar(&mut self, bar: &Bar) -> Option<IndicatorOutput>
fn alerts(&self) -> Vec<IndicatorAlert>
Source§fn on_checked_bar(
&mut self,
bar: &Bar,
) -> Result<Option<IndicatorOutput>, BarValidationError>
fn on_checked_bar( &mut self, bar: &Bar, ) -> Result<Option<IndicatorOutput>, BarValidationError>
Validates a bar before forwarding it to
Indicator::on_bar.Auto Trait Implementations§
impl Freeze for LsmaEngine
impl RefUnwindSafe for LsmaEngine
impl Send for LsmaEngine
impl Sync for LsmaEngine
impl Unpin for LsmaEngine
impl UnsafeUnpin for LsmaEngine
impl UnwindSafe for LsmaEngine
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