pub struct FastStochastic { /* private fields */ }
Expand description
Fast stochastic oscillator.
The stochastic oscillator is a momentum indicator comparing the closing price of a security to the range of its prices over a certain period of time.
§Formula
Where:
- %Kt - value of fast stochastic oscillator
- Ct - close price of the current period
- Ln - lowest price for the last n periods
- Hn - highest price for the last n periods
§Parameters
- length - number of periods (integer greater than 0). Default is 14.
§Example
use ta::indicators::FastStochastic;
use ta::{Calculate, Next};
let mut stoch = FastStochastic::new(5).unwrap();
assert_eq!(stoch.calc(20.0), 50.0);
assert_eq!(stoch.calc(30.0), 100.0);
assert_eq!(stoch.calc(40.0), 100.0);
assert_eq!(stoch.calc(35.0), 75.0);
assert_eq!(stoch.calc(15.0), 0.0);
Implementations§
Trait Implementations§
Source§impl Clone for FastStochastic
impl Clone for FastStochastic
Source§fn clone(&self) -> FastStochastic
fn clone(&self) -> FastStochastic
Returns a copy of the value. Read more
1.0.0 · 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 FastStochastic
impl Debug for FastStochastic
Source§impl Default for FastStochastic
impl Default for FastStochastic
Source§impl Display for FastStochastic
impl Display for FastStochastic
Auto Trait Implementations§
impl Freeze for FastStochastic
impl RefUnwindSafe for FastStochastic
impl Send for FastStochastic
impl Sync for FastStochastic
impl Unpin for FastStochastic
impl UnwindSafe for FastStochastic
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