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.

RSI

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.