pub struct ProjectionOscillator { /* private fields */ }Expand description
Projection Oscillator: where the close sits inside the projection bands,
scaled to 0..100.
The companion to ProjectionBands from Mel
Widner’s May 1995 Stocks & Commodities article. It maps the close onto the
[lower, upper] projection envelope:
PO = 100 · (close − lower) / (upper − lower)PO = 0 means the close is sitting on the lower band, PO = 100 on the
upper band, and PO = 50 at the midline. Because the bands by construction
bracket every projected high and low, the close almost always falls inside
them and the oscillator stays in 0..100 — readings near the extremes flag
an overbought/oversold position relative to the trend-tilted channel
rather than to a horizontal level. When the bands collapse (a zero-range
window, upper == lower) the position is undefined and the oscillator
returns the neutral 50.0.
§Example
use wickra_core::{Candle, Indicator, ProjectionOscillator};
let mut indicator = ProjectionOscillator::new(14).unwrap();
let mut last = None;
for i in 0..30 {
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§
Trait Implementations§
Source§impl Clone for ProjectionOscillator
impl Clone for ProjectionOscillator
Source§fn clone(&self) -> ProjectionOscillator
fn clone(&self) -> ProjectionOscillator
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 ProjectionOscillator
impl Debug for ProjectionOscillator
Source§impl Indicator for ProjectionOscillator
impl Indicator for ProjectionOscillator
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 ProjectionOscillator
impl RefUnwindSafe for ProjectionOscillator
impl Send for ProjectionOscillator
impl Sync for ProjectionOscillator
impl Unpin for ProjectionOscillator
impl UnsafeUnpin for ProjectionOscillator
impl UnwindSafe for ProjectionOscillator
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