pub struct ParabolicSAR {
pub state: ParabolicSARState,
}Expand description
Parabolic SAR (Stop and Reverse) Indicator
Parabolic SAR is a trend-following indicator that provides stop-loss levels and potential reversal points. It accelerates when the trend continues.
Formula:
- Uptrend: SAR = Previous SAR + AF × (EP - Previous SAR)
- Downtrend: SAR = Previous SAR + AF × (EP - Previous SAR)
Where:
- AF = Acceleration Factor (starts at 0.02, increments by 0.02, max 0.20)
- EP = Extreme Point (highest high in uptrend, lowest low in downtrend)
Fields§
§state: ParabolicSARStateImplementations§
Source§impl ParabolicSAR
impl ParabolicSAR
Sourcepub fn with_acceleration(
start: f64,
increment: f64,
maximum: f64,
) -> Result<Self, ParabolicSARError>
pub fn with_acceleration( start: f64, increment: f64, maximum: f64, ) -> Result<Self, ParabolicSARError>
Create a new Parabolic SAR calculator with custom acceleration parameters
Sourcepub fn with_config(config: ParabolicSARConfig) -> Self
pub fn with_config(config: ParabolicSARConfig) -> Self
Create a new Parabolic SAR calculator with custom configuration
Sourcepub fn calculate(
&mut self,
input: ParabolicSARInput,
) -> Result<ParabolicSAROutput, ParabolicSARError>
pub fn calculate( &mut self, input: ParabolicSARInput, ) -> Result<ParabolicSAROutput, ParabolicSARError>
Calculate Parabolic SAR for the given input
Sourcepub fn calculate_batch(
&mut self,
inputs: &[ParabolicSARInput],
) -> Result<Vec<ParabolicSAROutput>, ParabolicSARError>
pub fn calculate_batch( &mut self, inputs: &[ParabolicSARInput], ) -> Result<Vec<ParabolicSAROutput>, ParabolicSARError>
Calculate Parabolic SAR for a batch of inputs
Sourcepub fn get_state(&self) -> &ParabolicSARState
pub fn get_state(&self) -> &ParabolicSARState
Get current state (for serialization/debugging)
Sourcepub fn set_state(&mut self, state: ParabolicSARState)
pub fn set_state(&mut self, state: ParabolicSARState)
Restore state (for deserialization)
Sourcepub fn current_trend(&self) -> Option<TrendDirection>
pub fn current_trend(&self) -> Option<TrendDirection>
Get current trend direction
Sourcepub fn current_acceleration_factor(&self) -> f64
pub fn current_acceleration_factor(&self) -> f64
Get current acceleration factor
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ParabolicSAR
impl RefUnwindSafe for ParabolicSAR
impl Send for ParabolicSAR
impl Sync for ParabolicSAR
impl Unpin for ParabolicSAR
impl UnwindSafe for ParabolicSAR
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