Skip to main content

Indicators

Struct Indicators 

Source
pub struct Indicators {
Show 29 fields pub opens: VecDeque<f64>, pub highs: VecDeque<f64>, pub lows: VecDeque<f64>, pub closes: VecDeque<f64>, pub volumes: VecDeque<f64>, pub times: VecDeque<i64>, pub vwap: Option<f64>, pub ema: Option<f64>, pub st: Option<f64>, pub st_dir_pub: i8, pub atr: Option<f64>, pub cluster: usize, pub dyn_ema_pub: Option<f64>, pub ts_speed: f64, pub ts_norm: f64, pub ts_bullish: bool, pub bull_avg: f64, pub bear_avg: f64, pub dominance: f64, pub ao: f64, pub ao_rising: bool, pub wr_pct: f64, pub mom_pct: f64, pub wave_ok_long: bool, pub wave_ok_short: bool, pub mom_ok_long: bool, pub mom_ok_short: bool, pub hurst: f64, pub price_accel: f64, /* private fields */
}
Expand description

Full indicator engine (Layers 1–4, 9–11).

Call Indicators::update once per closed candle. After training_period candles, Indicators::st and related fields become Some.

Fields§

§opens: VecDeque<f64>§highs: VecDeque<f64>§lows: VecDeque<f64>§closes: VecDeque<f64>§volumes: VecDeque<f64>§times: VecDeque<i64>§vwap: Option<f64>

Layer 1 — intraday VWAP, resets at UTC midnight.

§ema: Option<f64>

Layer 2 — EMA of configurable period.

§st: Option<f64>

Layer 3 — SuperTrend line value.

§st_dir_pub: i8

Layer 3 — SuperTrend direction: -1 = bullish (price above ST), +1 = bearish.

§atr: Option<f64>

Layer 3 — RMA ATR used for SuperTrend.

§cluster: usize

Layer 3 — KMeans cluster index (0 = high vol, 1 = mid, 2 = low vol).

§dyn_ema_pub: Option<f64>

Layer 4 — dynamic EMA.

§ts_speed: f64

Layer 4 — HMA-smoothed wave speed.

§ts_norm: f64

Layer 4 — wave speed normalised 0–1.

§ts_bullish: bool

Layer 4 — true when wave speed is positive.

§bull_avg: f64

Layer 4 — average bull wave magnitude.

§bear_avg: f64

Layer 4 — average bear wave magnitude.

§dominance: f64

Layer 4 — bull_avg - |bear_avg|.

§ao: f64

Layer 9 — Awesome Oscillator value.

§ao_rising: bool

Layer 9 — true when AO is rising.

§wr_pct: f64

Layer 9 — wave ratio percentile.

§mom_pct: f64

Layer 9 — momentum percentile.

§wave_ok_long: bool§wave_ok_short: bool§mom_ok_long: bool§mom_ok_short: bool§hurst: f64

Layer 10 — Hurst exponent (0.5 = random, >0.52 = trending).

§price_accel: f64

Layer 11 — normalised price acceleration (−1 to +1).

Implementations§

Source§

impl Indicators

Source

pub fn new(s: &BotSettings) -> Self

Source

pub fn update(&mut self, candle: &Candle) -> bool

Feed one closed candle. Returns true once SuperTrend is ready.

Source

pub fn check_speed_exit(&self, position: i32) -> bool

Returns true if a speed-exit condition is triggered for the given position. position: +1 = long, -1 = short.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.