pub struct KagiBars { /* private fields */ }Expand description
Kagi bar builder using the fixed reversal-amount method on close prices.
A Kagi chart is one continuous line that extends in its current direction as
long as price makes new extremes, and turns when price retraces by at least
reversal from the latest extreme. This builder emits the completed
segment each time the line turns:
- The first candle seeds the start price; the first subsequent move (of any size) sets the initial direction.
- While the trend holds, new extremes extend the current segment silently.
- A retracement of
>= reversalcloses the current segment (returned fromBarBuilder::update) and starts a new one in the opposite direction.
At most one segment completes per candle, so update returns either an empty
vector or a single KagiBar.
§Example
use wickra_core::{BarBuilder, Candle, KagiBars};
let flat = |price: f64| Candle::new(price, price, price, price, 1.0, 0).unwrap();
let mut kagi = KagiBars::new(2.0).unwrap();
kagi.update(flat(10.0)); // seed
kagi.update(flat(15.0)); // rise to 15
let bars = kagi.update(flat(12.0)); // retrace >= 2 -> closes the up segment
assert_eq!(bars.len(), 1);
assert_eq!(bars[0].direction, 1);Implementations§
Trait Implementations§
Source§impl BarBuilder for KagiBars
impl BarBuilder for KagiBars
Auto Trait Implementations§
impl Freeze for KagiBars
impl RefUnwindSafe for KagiBars
impl Send for KagiBars
impl Sync for KagiBars
impl Unpin for KagiBars
impl UnsafeUnpin for KagiBars
impl UnwindSafe for KagiBars
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more