pub struct Qqe { /* private fields */ }Expand description
QQE — Quantitative Qualitative Estimation (Igor Livshin).
QQE smooths the RSI, then builds an “ATR of the RSI” trailing stop around it. Crossovers of the smoothed RSI and that trailing line give cleaner momentum signals than the raw RSI:
rsi_ma = EMA(RSI(price, rsi_period), smoothing)
atr_rsi = |rsi_ma − rsi_ma_prev|
ma_atr = EMA(atr_rsi, 2·rsi_period − 1) // Wilder length
dar = EMA(ma_atr, 2·rsi_period − 1) · factor // smoothed band width
long_band = (rsi_ma_prev > long_band_prev && rsi_ma > long_band_prev)
? max(long_band_prev, rsi_ma − dar) : rsi_ma − dar
short_band = (rsi_ma_prev < short_band_prev && rsi_ma < short_band_prev)
? min(short_band_prev, rsi_ma + dar) : rsi_ma + dar
trend = cross-up of short_band → +1, cross-down of long_band → −1, else hold
trailing = trend == +1 ? long_band : short_bandThe trailing line ratchets in the trend direction (only ever tightening until
the smoothed RSI crosses it), exactly like a SuperTrend
on the RSI. Livshin’s defaults are rsi_period = 14, smoothing = 5,
factor = 4.236.
§Example
use wickra_core::{Indicator, Qqe};
let mut qqe = Qqe::new(14, 5, 4.236).unwrap();
let mut last = None;
for i in 0..200 {
last = qqe.update(100.0 + (f64::from(i) * 0.1).sin() * 8.0);
}
assert!(last.is_some());Implementations§
Trait Implementations§
Source§impl Indicator for Qqe
impl Indicator for Qqe
Source§fn update(&mut self, price: f64) -> Option<QqeOutput>
fn update(&mut self, price: f64) -> Option<QqeOutput>
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 Qqe
impl RefUnwindSafe for Qqe
impl Send for Qqe
impl Sync for Qqe
impl Unpin for Qqe
impl UnsafeUnpin for Qqe
impl UnwindSafe for Qqe
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