pub struct MurreyMathLines { /* private fields */ }Expand description
Murrey Math Lines — T. H. Murrey’s grid that divides the recent trading range into eighths, each acting as support/resistance.
HH = highest high over `period`, LL = lowest low over `period`
step = (HH − LL) / 8
mm{i}_8 = LL + i · step for i = 0..8Murrey Math (a Gann-derived framework) holds that price gravitates to and reverses at the eighth divisions of its range. The 4/8 line is the major pivot (mean); 0/8 and 8/8 are the strongest support and resistance; 3/8 and 5/8 bound the “normal” trading range, while 1/8/7/8 are the weak “stall and reverse” lines. This implementation uses the price-derived eighths over a rolling high-low frame (the practical core of the method) rather than Murrey’s full octave-quantised frame sizing, so the levels track the instrument’s actual recent range.
The first value lands after period inputs; each update rescans the frame in
O(period). A degenerate flat frame (HH == LL) collapses every line onto the
price.
§Example
use wickra_core::{Candle, Indicator, MurreyMathLines};
let mut indicator = MurreyMathLines::new(64).unwrap();
let mut last = None;
for i in 0..120 {
let base = 100.0 + (f64::from(i) * 0.3).sin() * 10.0;
let c = Candle::new(base, base + 1.0, base - 1.0, base, 1_000.0, 0).unwrap();
last = indicator.update(c);
}
assert!(last.is_some());Implementations§
Source§impl MurreyMathLines
impl MurreyMathLines
Sourcepub fn new(period: usize) -> Result<Self>
pub fn new(period: usize) -> Result<Self>
Construct Murrey Math Lines over a period-bar high-low frame.
§Errors
Returns Error::PeriodZero if period == 0.
Sourcepub const fn value(&self) -> Option<MurreyMathLinesOutput>
pub const fn value(&self) -> Option<MurreyMathLinesOutput>
Current value if available.
Trait Implementations§
Source§impl Clone for MurreyMathLines
impl Clone for MurreyMathLines
Source§fn clone(&self) -> MurreyMathLines
fn clone(&self) -> MurreyMathLines
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 MurreyMathLines
impl Debug for MurreyMathLines
Source§impl Indicator for MurreyMathLines
impl Indicator for MurreyMathLines
Source§type Input = Candle
type Input = Candle
f64 for a price, or Candle / Tick).Source§type Output = MurreyMathLinesOutput
type Output = MurreyMathLinesOutput
Source§fn update(&mut self, candle: Candle) -> Option<MurreyMathLinesOutput>
fn update(&mut self, candle: Candle) -> Option<MurreyMathLinesOutput>
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 MurreyMathLines
impl RefUnwindSafe for MurreyMathLines
impl Send for MurreyMathLines
impl Sync for MurreyMathLines
impl Unpin for MurreyMathLines
impl UnsafeUnpin for MurreyMathLines
impl UnwindSafe for MurreyMathLines
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