Struct ADX

Source
pub struct ADX { /* private fields */ }
Expand description

Average Directional Index (ADX) Indicator

ADX measures trend strength regardless of direction. It’s composed of:

  • True Range (TR): Max of (H-L), (H-Cp), (Cp-L)
  • Directional Movement: +DM = H-Hp (if positive), -DM = Lp-L (if positive)
  • Directional Indicators: +DI = (+DM smoothed / TR smoothed) * 100
  • Directional Index: DX = (|+DI - -DI| / (+DI + -DI)) * 100
  • ADX = Smoothed average of DX values

ADX interpretation:

  • 0-25: Weak trend or ranging market
  • 25-50: Strong trend
  • 50+: Very strong trend

Implementations§

Source§

impl ADX

Source

pub fn new() -> Self

Create a new ADX calculator with default configuration (period=14)

Source

pub fn with_period(period: usize) -> Result<Self, ADXError>

Create a new ADX calculator with custom period

Source

pub fn with_periods( period: usize, adx_smoothing: usize, ) -> Result<Self, ADXError>

Create a new ADX calculator with custom period and ADX smoothing

Source

pub fn with_config(config: ADXConfig) -> Self

Create a new ADX calculator with custom configuration

Source

pub fn calculate(&mut self, input: ADXInput) -> Result<ADXOutput, ADXError>

Calculate ADX for the given input

Source

pub fn calculate_batch( &mut self, inputs: &[ADXInput], ) -> Result<Vec<ADXOutput>, ADXError>

Calculate ADX for a batch of inputs

Source

pub fn reset(&mut self)

Reset the calculator state

Source

pub fn get_state(&self) -> &ADXState

Get current state (for serialization/debugging)

Source

pub fn set_state(&mut self, state: ADXState)

Restore state (for deserialization)

Source

pub fn trend_strength(&self) -> TrendStrength

Get current trend strength

Source

pub fn trend_direction(&self) -> Option<TrendDirection>

Get current trend direction

Trait Implementations§

Source§

impl Default for ADX

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for ADX

§

impl RefUnwindSafe for ADX

§

impl Send for ADX

§

impl Sync for ADX

§

impl Unpin for ADX

§

impl UnwindSafe for ADX

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.