pub struct CentralPivotRange { /* private fields */ }Expand description
Central Pivot Range (CPR) — the classic pivot point flanked by two “central” levels whose separation gauges the day’s expected character.
pivot = (high + low + close) / 3
bc' = (high + low) / 2
tc' = 2·pivot − bc'
TC = max(tc', bc'), BC = min(tc', bc')The CPR is computed from the previous period’s bar (feed it completed
daily/weekly bars). The width of the range TC − BC is the headline read: a
narrow CPR signals a likely trending day (price has little balance area to
chew through), while a wide CPR signals a likely range-bound, balanced
day. Price opening above the whole range is bullish, below it bearish, inside
it neutral. The tc'/bc' formulas are symmetric about the pivot; this
implementation labels the larger as TC and the smaller as BC so TC >= BC
always holds.
There are no parameters and no warmup — each completed bar yields one CPR.
Each update is O(1).
§Example
use wickra_core::{Candle, Indicator, CentralPivotRange};
let mut indicator = CentralPivotRange::new();
let prev_day = Candle::new(101.0, 110.0, 90.0, 105.0, 1_000.0, 0).unwrap();
let cpr = indicator.update(prev_day).unwrap();
assert!(cpr.tc >= cpr.bc);Implementations§
Trait Implementations§
Source§impl Clone for CentralPivotRange
impl Clone for CentralPivotRange
Source§fn clone(&self) -> CentralPivotRange
fn clone(&self) -> CentralPivotRange
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 CentralPivotRange
impl Debug for CentralPivotRange
Source§impl Default for CentralPivotRange
impl Default for CentralPivotRange
Source§fn default() -> CentralPivotRange
fn default() -> CentralPivotRange
Source§impl Indicator for CentralPivotRange
impl Indicator for CentralPivotRange
Source§type Input = Candle
type Input = Candle
f64 for a price, or Candle / Tick).Source§type Output = CentralPivotRangeOutput
type Output = CentralPivotRangeOutput
Source§fn update(&mut self, candle: Candle) -> Option<CentralPivotRangeOutput>
fn update(&mut self, candle: Candle) -> Option<CentralPivotRangeOutput>
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 CentralPivotRange
impl RefUnwindSafe for CentralPivotRange
impl Send for CentralPivotRange
impl Sync for CentralPivotRange
impl Unpin for CentralPivotRange
impl UnsafeUnpin for CentralPivotRange
impl UnwindSafe for CentralPivotRange
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