Class: RubyTechnicalAnalysis::ChandeMomentumOscillator
- Defined in:
- lib/ruby_technical_analysis/indicators/chande_momentum_oscillator.rb
Overview
Chande Momentum Oscillator
Find more information at: www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/cmo
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 Chande Momentum Oscillator value.
-
#initialize(series: [], period: 20) ⇒ ChandeMomentumOscillator
constructor
A new instance of ChandeMomentumOscillator.
-
#valid? ⇒ Boolean
Whether or not the object is valid.
Methods inherited from Indicator
Constructor Details
#initialize(series: [], period: 20) ⇒ ChandeMomentumOscillator
Returns a new instance of ChandeMomentumOscillator.
10 11 12 13 14 15 16 |
# File 'lib/ruby_technical_analysis/indicators/chande_momentum_oscillator.rb', line 10 def initialize(series: [], period: 20) @period = period @up_change_sum = 0 @down_change_sum = 0 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/chande_momentum_oscillator.rb', line 6 def period @period end |
Instance Method Details
#call ⇒ Float
Returns The current Chande Momentum Oscillator value.
19 20 21 |
# File 'lib/ruby_technical_analysis/indicators/chande_momentum_oscillator.rb', line 19 def call calculate_cmo end |
#valid? ⇒ Boolean
Returns Whether or not the object is valid.
24 25 26 |
# File 'lib/ruby_technical_analysis/indicators/chande_momentum_oscillator.rb', line 24 def valid? period + 1 <= series.length end |