pub struct ThreeLineBreak { /* private fields */ }Expand description
Three Line Break — the trend direction of a line-break (“kakushi”) chart, where
a reversal requires the close to break the extreme of the last lines lines.
continue the trend when close exceeds the prior line's end
reverse the trend when close breaks beyond the extreme of the last `lines` lines
output = current line direction: +1 (up), −1 (down)A line-break chart ignores time and small moves entirely: it draws a new line
only when the close makes a new extreme in the trend, and flips direction only
when the close reverses past the high (or low) of the last lines lines —
classically three. This filters out minor pullbacks, so the emitted
direction stays in a trend until a genuinely significant reversal. Distinct from
the candlestick ThreeLineStrike (a fixed four-bar
pattern); this is the line-break chart type reduced to its trend state. See
also the alt-chart “Three-Line-Break Bars” builder.
The output is +1.0 / −1.0. The first bar seeds the reference price; the
direction is emitted once the first line is drawn (data-dependent;
warmup_period returns the minimum 2). Each update is O(lines).
§Example
use wickra_core::{Candle, Indicator, ThreeLineBreak};
let mut indicator = ThreeLineBreak::new(3).unwrap();
let mut last = None;
for i in 0..20 {
let close = 100.0 + f64::from(i);
let c = Candle::new(close, close, close, close, 1_000.0, 0).unwrap();
last = indicator.update(c);
}
assert_eq!(last, Some(1.0));Implementations§
Source§impl ThreeLineBreak
impl ThreeLineBreak
Trait Implementations§
Source§impl Clone for ThreeLineBreak
impl Clone for ThreeLineBreak
Source§fn clone(&self) -> ThreeLineBreak
fn clone(&self) -> ThreeLineBreak
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ThreeLineBreak
impl Debug for ThreeLineBreak
Source§impl Indicator for ThreeLineBreak
impl Indicator for ThreeLineBreak
Source§type Input = Candle
type Input = Candle
f64 for a price, or Candle / Tick).Source§fn update(&mut self, candle: Candle) -> Option<f64>
fn update(&mut self, candle: Candle) -> Option<f64>
None if the indicator is still warming up.Source§fn reset(&mut self)
fn reset(&mut self)
Source§fn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
None output can be produced.Auto Trait Implementations§
impl Freeze for ThreeLineBreak
impl RefUnwindSafe for ThreeLineBreak
impl Send for ThreeLineBreak
impl Sync for ThreeLineBreak
impl Unpin for ThreeLineBreak
impl UnsafeUnpin for ThreeLineBreak
impl UnwindSafe for ThreeLineBreak
Blanket Implementations§
Source§impl<T> BatchExt for Twhere
T: Indicator,
impl<T> BatchExt for Twhere
T: Indicator,
Source§fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
None during warmup) per input.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