Class: RubyTechnicalAnalysis::RelativeStrengthIndex
- Defined in:
- lib/ruby_technical_analysis/indicators/relative_strength_index.rb
Overview
Relative Strength Index
Find more information at: www.fidelity.com/viewpoints/active-investor/how-to-use-RSI
Instance Attribute Summary collapse
-
#period ⇒ Object
readonly
Returns the value of attribute period.
Attributes inherited from Indicator
Instance Method Summary collapse
-
#call ⇒ Float
The current RSI value.
-
#initialize(series: [], period: 14) ⇒ RelativeStrengthIndex
constructor
A new instance of RelativeStrengthIndex.
-
#valid? ⇒ Boolean
Whether or not the object is valid.
Methods inherited from Indicator
Constructor Details
#initialize(series: [], period: 14) ⇒ RelativeStrengthIndex
Returns a new instance of RelativeStrengthIndex.
10 11 12 13 14 15 16 17 18 |
# File 'lib/ruby_technical_analysis/indicators/relative_strength_index.rb', line 10 def initialize(series: [], period: 14) @period = period @rsi = [] @smooth_up = [] @smooth_down = [] @wilders_is_set = false super(series: series) end |
Instance Attribute Details
#period ⇒ Object (readonly)
Returns the value of attribute period.
6 7 8 |
# File 'lib/ruby_technical_analysis/indicators/relative_strength_index.rb', line 6 def period @period end |
Instance Method Details
#call ⇒ Float
Returns The current RSI value.
21 22 23 |
# File 'lib/ruby_technical_analysis/indicators/relative_strength_index.rb', line 21 def call calculate_rsi end |
#valid? ⇒ Boolean
Returns Whether or not the object is valid.
26 27 28 |
# File 'lib/ruby_technical_analysis/indicators/relative_strength_index.rb', line 26 def valid? period < series.length end |