pub struct ChandelierExit { /* private fields */ }Expand description
Chandelier Exit — Chuck LeBeau’s ATR trailing stop, hung from the highest high (for longs) or the lowest low (for shorts) of the lookback window.
long_stop = highest_high(period) − multiplier · ATR(period)
short_stop = lowest_low(period) + multiplier · ATR(period)A long position is exited when price closes below long_stop; a short
when it closes above short_stop. Because the stop hangs a fixed number
of ATRs off the extreme of the window — like a chandelier off a ceiling —
it follows price up but never loosens. LeBeau’s classic configuration is a
22-bar window with a 3.0 multiplier.
§Example
use wickra_core::{Candle, Indicator, ChandelierExit};
let mut indicator = ChandelierExit::new(22, 3.0).unwrap();
let mut last = None;
for i in 0..80 {
let base = 100.0 + f64::from(i);
let candle =
Candle::new(base, base + 2.0, base - 2.0, base + 1.0, 10.0, i64::from(i)).unwrap();
last = indicator.update(candle);
}
assert!(last.is_some());Implementations§
Source§impl ChandelierExit
impl ChandelierExit
Sourcepub fn new(period: usize, multiplier: f64) -> Result<ChandelierExit, Error>
pub fn new(period: usize, multiplier: f64) -> Result<ChandelierExit, Error>
Construct a Chandelier Exit with an explicit window and band multiplier.
§Errors
Returns Error::PeriodZero if period == 0 and
Error::NonPositiveMultiplier if multiplier is not strictly
positive and finite.
Sourcepub fn classic() -> ChandelierExit
pub fn classic() -> ChandelierExit
LeBeau’s classic configuration: a 22-bar window, 3.0 multiplier.
Trait Implementations§
Source§impl Clone for ChandelierExit
impl Clone for ChandelierExit
Source§fn clone(&self) -> ChandelierExit
fn clone(&self) -> ChandelierExit
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ChandelierExit
impl Debug for ChandelierExit
Source§impl Indicator for ChandelierExit
impl Indicator for ChandelierExit
Source§type Input = Candle
type Input = Candle
Type of one input data point (typically
f64 for a price, or Candle / Tick).Source§type Output = ChandelierExitOutput
type Output = ChandelierExitOutput
Type of one output value.
Source§fn update(&mut self, candle: Candle) -> Option<ChandelierExitOutput>
fn update(&mut self, candle: Candle) -> Option<ChandelierExitOutput>
Feed one new data point into the indicator and return the freshly computed
output, or
None if the indicator is still warming up.Source§fn reset(&mut self)
fn reset(&mut self)
Reset all internal state, leaving the indicator equivalent to a freshly
constructed instance with the same parameters.
Source§fn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
Number of inputs required before the first non-
None output can be produced.Auto Trait Implementations§
impl Freeze for ChandelierExit
impl RefUnwindSafe for ChandelierExit
impl Send for ChandelierExit
impl Sync for ChandelierExit
impl Unpin for ChandelierExit
impl UnsafeUnpin for ChandelierExit
impl UnwindSafe for ChandelierExit
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>>
Run the indicator over a slice of inputs in order, returning one output (or
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
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