pub struct RangeBars { /* private fields */ }Expand description
Range bar builder using a fixed price increment on close prices.
A range bar completes every time price travels a fixed range from the current
anchor, in either direction. This is the key difference from
RenkoBars: Renko imposes a 2 * box_size penalty to
reverse direction, so it filters out small oscillations; range bars have no
reversal penalty — a move of exactly range against the trend prints a bar
immediately. Range bars therefore track every leg of price movement, while Renko
smooths them.
Construction rules:
- The first candle seeds the anchor and prints no bar.
- Each subsequent candle prints one bar for every
rangeof close movement away from the anchor; a candle that gaps several ranges prints them all in oneBarBuilder::updatecall. - Bars are aligned to the
rangegrid relative to the seed price.
§Example
use wickra_core::{BarBuilder, Candle, RangeBars};
let flat = |price: f64| Candle::new(price, price, price, price, 1.0, 0).unwrap();
let mut bars = RangeBars::new(1.0).unwrap();
assert!(bars.update(flat(10.0)).is_empty()); // seed
let up = bars.update(flat(12.0)); // +2 ranges
assert_eq!(up.len(), 2);
let down = bars.update(flat(11.0)); // -1 range, no penalty
assert_eq!(down.len(), 1);Implementations§
Trait Implementations§
Source§impl BarBuilder for RangeBars
impl BarBuilder for RangeBars
Auto Trait Implementations§
impl Freeze for RangeBars
impl RefUnwindSafe for RangeBars
impl Send for RangeBars
impl Sync for RangeBars
impl Unpin for RangeBars
impl UnsafeUnpin for RangeBars
impl UnwindSafe for RangeBars
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