pub struct Atr { /* private fields */ }Expand description
Average True Range indicator.
Measures market volatility by decomposing the entire range of an asset price for a given period. ATR uses the greatest of:
- Current high minus current low
- Absolute value of current high minus previous close
- Absolute value of current low minus previous close
§Formula
True Range = max(high - low, |high - prev_close|, |low - prev_close|) ATR = Smoothed average of True Range over period
§Example
use quant_indicators::{Indicator, Atr};
use quant_primitives::Candle;
use chrono::Utc;
use rust_decimal_macros::dec;
let ts = Utc::now();
let candles: Vec<Candle> = (0..20).map(|i| {
let d = rust_decimal::Decimal::from(i);
Candle::new(dec!(100) + d, dec!(110) + d, dec!(90) + d, dec!(100) + d, dec!(1000), ts).unwrap()
}).collect();
let atr = Atr::new(14).unwrap();
let series = atr.compute(&candles).unwrap();Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Atr
impl RefUnwindSafe for Atr
impl Send for Atr
impl Sync for Atr
impl Unpin for Atr
impl UnsafeUnpin 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