[−][src]Struct ta::indicators::RelativeStrengthIndex
The relative strength index (RSI).
It is a momentum oscillator, that compares the magnitude of recent gains and losses over a specified time period to measure speed and change of price movements of a security. It is primarily used to attempt to identify overbought or oversold conditions in the trading of an asset.
The oscillator returns output in the range of 0..100.
Formula
RSIt = EMAUt * 100 / (EMAUt + EMADt)
Where:
- RSIt - value of RSI indicator in a moment of time t
- EMAUt - value of EMA of up periods in a moment of time t
- EMADt - value of EMA of down periods in a moment of time t
If current period has value higher than previous period, than:
U = pt - pt-1
D = 0
Otherwise:
U = 0
D = pt-1 - pt
Where:
- U = up period value
- D = down period value
- pt - input value in a moment of time t
- pt-1 - input value in a moment of time t-1
Parameters
- n - number of periods (integer greater than 0). Default value is 14.
Example
use ta::indicators::RelativeStrengthIndex; use ta::Next; let mut rsi = RelativeStrengthIndex::new(3).unwrap(); assert_eq!(rsi.next(10.0), 50.0); assert_eq!(rsi.next(10.5).round(), 86.0); assert_eq!(rsi.next(10.0).round(), 35.0); assert_eq!(rsi.next(9.5).round(), 16.0);
Links
Methods
impl RelativeStrengthIndex
[src]
Trait Implementations
impl Clone for RelativeStrengthIndex
[src]
fn clone(&self) -> RelativeStrengthIndex
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for RelativeStrengthIndex
[src]
impl Default for RelativeStrengthIndex
[src]
impl Display for RelativeStrengthIndex
[src]
impl<'a, T: Close> Next<&'a T> for RelativeStrengthIndex
[src]
impl Next<f64> for RelativeStrengthIndex
[src]
impl Reset for RelativeStrengthIndex
[src]
Auto Trait Implementations
impl RefUnwindSafe for RelativeStrengthIndex
impl Send for RelativeStrengthIndex
impl Sync for RelativeStrengthIndex
impl Unpin for RelativeStrengthIndex
impl UnwindSafe for RelativeStrengthIndex
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,