pub struct ShortLine { /* private fields */ }Expand description
Short Line — a single candle whose range is shorter than the recent average
while its body still dominates that (small) range: a compact directional bar.
As with LongLine, “short” only has meaning relative to
recent activity, so the detector compares each candle’s range against a rolling
average of the previous period ranges.
avg = mean range of the previous `period` candles
short line = range < avg AND |close − open| >= 0.5 * range
white -> +1.0, black -> −1.0Output is +1.0 (short white line), −1.0 (short black line), or 0.0
otherwise. The first period candles return 0.0 while the rolling average
fills. period defaults to 5 and must be at least 1. Pattern-shape check
only — no trend filter is applied; combine with a trend indicator for
actionable signals.
§Signed ±1 encoding
This detector emits the uniform candlestick sign convention shared across the
pattern family — +1.0 bullish, −1.0 bearish, 0.0 no pattern — so it
drops straight into a machine-learning feature matrix as a single dimension.
§Example
use wickra_core::{Candle, Indicator, ShortLine};
let mut indicator = ShortLine::new();
// Five wide bars fill the rolling average.
for ts in 0..5 {
indicator.update(Candle::new(10.0, 13.0, 9.5, 12.9, 1.0, ts).unwrap());
}
// A compact solid white bar is a short white line.
let out = indicator
.update(Candle::new(10.0, 11.0, 9.9, 10.9, 1.0, 5).unwrap());
assert_eq!(out, Some(1.0));Implementations§
Trait Implementations§
Source§impl Indicator for ShortLine
impl Indicator for ShortLine
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 ShortLine
impl RefUnwindSafe for ShortLine
impl Send for ShortLine
impl Sync for ShortLine
impl Unpin for ShortLine
impl UnsafeUnpin for ShortLine
impl UnwindSafe for ShortLine
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