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
impl ADX
Sourcepub fn with_period(period: usize) -> Result<Self, ADXError>
pub fn with_period(period: usize) -> Result<Self, ADXError>
Create a new ADX calculator with custom period
Sourcepub fn with_periods(
period: usize,
adx_smoothing: usize,
) -> Result<Self, ADXError>
pub fn with_periods( period: usize, adx_smoothing: usize, ) -> Result<Self, ADXError>
Create a new ADX calculator with custom period and ADX smoothing
Sourcepub fn with_config(config: ADXConfig) -> Self
pub fn with_config(config: ADXConfig) -> Self
Create a new ADX calculator with custom configuration
Sourcepub fn calculate(&mut self, input: ADXInput) -> Result<ADXOutput, ADXError>
pub fn calculate(&mut self, input: ADXInput) -> Result<ADXOutput, ADXError>
Calculate ADX for the given input
Sourcepub fn calculate_batch(
&mut self,
inputs: &[ADXInput],
) -> Result<Vec<ADXOutput>, ADXError>
pub fn calculate_batch( &mut self, inputs: &[ADXInput], ) -> Result<Vec<ADXOutput>, ADXError>
Calculate ADX for a batch of inputs
Sourcepub fn trend_strength(&self) -> TrendStrength
pub fn trend_strength(&self) -> TrendStrength
Get current trend strength
Sourcepub fn trend_direction(&self) -> Option<TrendDirection>
pub fn trend_direction(&self) -> Option<TrendDirection>
Get current trend direction
Trait Implementations§
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> 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