Struct ta::indicators::RelativeStrengthIndex [−][src]
pub struct RelativeStrengthIndex { /* fields omitted */ }
Expand description
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
- period - 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
Implementations
Trait Implementations
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
Mutably borrows from an owned value. Read more