pub struct ThreeLineBreakBars { /* private fields */ }Expand description
Three-Line-Break bar builder using the classic close-based reversal rule.
A line-break chart draws a new line in the trend direction whenever the close
makes a new extreme, and only reverses when the close breaks the extreme of the
previous lines lines (three by default — hence “three-line break”). This filters
minor noise: a pullback that fails to exceed the last three lines is ignored
entirely, so the chart isolates meaningful reversals.
This is the bar-builder counterpart of the
ThreeLineBreak indicator: the indicator reports the
current line state as a streaming value, whereas this builder emits each
completed line as a LineBreakBar so you can reconstruct the full line-break
chart. At most one line forms per candle, so BarBuilder::update returns either
an empty vector or a single bar.
Construction rules:
- The first candle seeds a reference close and prints nothing.
- The first subsequent move (up or down) draws the first line.
- In an up-trend a close above the last line’s top extends it (a new up line); a
close below the lowest low of the last
lineslines reverses to a down line. The down-trend is symmetric.
§Example
use wickra_core::{BarBuilder, Candle, ThreeLineBreakBars};
let flat = |price: f64| Candle::new(price, price, price, price, 1.0, 0).unwrap();
let mut bars = ThreeLineBreakBars::new(3).unwrap();
bars.update(flat(10.0)); // seed
let first = bars.update(flat(11.0)); // first up line
assert_eq!(first.len(), 1);
assert_eq!(first[0].direction, 1);Implementations§
Source§impl ThreeLineBreakBars
impl ThreeLineBreakBars
Trait Implementations§
Source§impl BarBuilder for ThreeLineBreakBars
impl BarBuilder for ThreeLineBreakBars
Source§type Bar = LineBreakBar
type Bar = LineBreakBar
Source§impl Clone for ThreeLineBreakBars
impl Clone for ThreeLineBreakBars
Source§fn clone(&self) -> ThreeLineBreakBars
fn clone(&self) -> ThreeLineBreakBars
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ThreeLineBreakBars
impl RefUnwindSafe for ThreeLineBreakBars
impl Send for ThreeLineBreakBars
impl Sync for ThreeLineBreakBars
impl Unpin for ThreeLineBreakBars
impl UnsafeUnpin for ThreeLineBreakBars
impl UnwindSafe for ThreeLineBreakBars
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
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>
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>
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