pub struct DirectionChanges { /* private fields */ }Expand description
Direction Changes — count of close-over-close reversals in the last period bars.
A reversal occurs when consecutive bar moves change sign: an up move followed by a down move, or vice versa. Requires 3 closes to detect the first reversal.
Interpretation:
- High count: choppy, mean-reverting market (many direction flips).
- Low count: trending market (sustained directional moves).
- Maximum possible:
period - 1(every bar reverses direction).
Returns SignalValue::Unavailable until period + 1 closes have been seen.
§Example
use fin_primitives::signals::indicators::DirectionChanges;
use fin_primitives::signals::Signal;
let dc = DirectionChanges::new("dc_10", 10).unwrap();
assert_eq!(dc.period(), 10);Implementations§
Trait Implementations§
Source§impl Signal for DirectionChanges
impl Signal for DirectionChanges
Source§fn period(&self) -> usize
fn period(&self) -> usize
Returns the number of bars required before the signal produces a value.
Source§fn is_ready(&self) -> bool
fn is_ready(&self) -> bool
Returns
true if the signal has accumulated enough bars to produce a value.Source§fn reset(&mut self)
fn reset(&mut self)
Resets the signal to its initial state as if no bars had been seen. Read more
Source§fn update_bar(&mut self, bar: &OhlcvBar) -> Result<SignalValue, FinError>
fn update_bar(&mut self, bar: &OhlcvBar) -> Result<SignalValue, FinError>
Auto Trait Implementations§
impl Freeze for DirectionChanges
impl RefUnwindSafe for DirectionChanges
impl Send for DirectionChanges
impl Sync for DirectionChanges
impl Unpin for DirectionChanges
impl UnsafeUnpin for DirectionChanges
impl UnwindSafe for DirectionChanges
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