pub struct ATR { /* private fields */ }Expand description
A simplified Average True Range (ATR) indicator.
This ATR calculates the true range as the absolute difference between the current closing price and the previous closing price. It then computes the ATR as the average of these true ranges over a specified period.
Implementations§
Source§impl ATR
impl ATR
Sourcepub fn calculate(&mut self, close: f64) -> Option<f64>
pub fn calculate(&mut self, close: f64) -> Option<f64>
Calculates the current ATR value using the latest closing price.
The true range is computed as the absolute difference between the current closing price and the previous closing price.
This true range is stored in a sliding window; once the window contains period values, the ATR is returned as their average.
§Arguments
close- The latest closing price.
§Returns
Some(f64)containing the ATR value if enough data is available.Noneif there aren’t enough values yet.
Auto Trait Implementations§
impl Freeze for ATR
impl RefUnwindSafe for ATR
impl Send for ATR
impl Sync for ATR
impl Unpin for ATR
impl UnwindSafe for ATR
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