pub struct T3 { /* private fields */ }Expand description
Tillson’s T3 — a six-fold cascaded EMA recombined with a volume factor v.
T3 is the generalised DEMA applied three times. Tim Tillson’s expansion of
that triple application over six chained EMAs (e1 … e6, each of the same
period) gives the closed form used here:
c1 = −v³
c2 = 3v² + 3v³
c3 = −6v² − 3v − 3v³
c4 = 1 + 3v + v³ + 3v²
T3 = c1·e6 + c2·e5 + c3·e4 + c4·e3The volume factor v ∈ [0, 1] controls the lag/smoothness trade-off:
v = 0 collapses T3 to the plain triple-cascaded EMA e3, while the
conventional v = 0.7 adds a hump that sharpens the response to turns.
The coefficients always sum to 1, so a constant series maps to itself.
The first output lands after 6·period − 5 inputs — the index at which the
sixth cascaded EMA seeds.
§Example
use wickra_core::{Indicator, T3};
let mut indicator = T3::new(5, 0.7).unwrap();
let mut last = None;
for i in 0..120 {
last = indicator.update(100.0 + f64::from(i));
}
assert!(last.is_some());Implementations§
Source§impl T3
impl T3
Sourcepub fn new(period: usize, v: f64) -> Result<Self>
pub fn new(period: usize, v: f64) -> Result<Self>
Construct a new T3 with the given period and volume factor v.
§Errors
Returns Error::PeriodZero if period == 0, or
Error::InvalidPeriod if v is non-finite or outside [0.0, 1.0].
Sourcepub const fn volume_factor(&self) -> f64
pub const fn volume_factor(&self) -> f64
Configured volume factor v.
Trait Implementations§
Source§impl Indicator for T3
impl Indicator for T3
Source§fn update(&mut self, input: f64) -> Option<f64>
fn update(&mut self, input: f64) -> Option<f64>
None if the indicator is still warming up.Source§fn reset(&mut self)
fn reset(&mut self)
Source§fn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
None output can be produced.Auto Trait Implementations§
impl Freeze for T3
impl RefUnwindSafe for T3
impl Send for T3
impl Sync for T3
impl Unpin for T3
impl UnsafeUnpin for T3
impl UnwindSafe for T3
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>>
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
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>
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>
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