Class: RubyTechnicalAnalysis::Macd
- Defined in:
- lib/ruby_technical_analysis/indicators/macd.rb
Overview
Moving Average Convergence Divergence (MACD)
Find more information at: www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/macd
Instance Attribute Summary collapse
-
#fast_period ⇒ Object
readonly
Returns the value of attribute fast_period.
-
#signal_period ⇒ Object
readonly
Returns the value of attribute signal_period.
-
#slow_period ⇒ Object
readonly
Returns the value of attribute slow_period.
Attributes inherited from Indicator
Instance Method Summary collapse
-
#call ⇒ Array
An array containing the current MACD line, signal line, and histogram values.
-
#initialize(series: [], fast_period: 12, slow_period: 26, signal_period: 9) ⇒ Macd
constructor
A new instance of Macd.
-
#valid? ⇒ Boolean
Whether or not the object is valid.
Methods inherited from Indicator
Constructor Details
#initialize(series: [], fast_period: 12, slow_period: 26, signal_period: 9) ⇒ Macd
Returns a new instance of Macd.
12 13 14 15 16 17 18 |
# File 'lib/ruby_technical_analysis/indicators/macd.rb', line 12 def initialize(series: [], fast_period: 12, slow_period: 26, signal_period: 9) @fast_period = fast_period @slow_period = slow_period @signal_period = signal_period super(series: series) end |
Instance Attribute Details
#fast_period ⇒ Object (readonly)
Returns the value of attribute fast_period.
6 7 8 |
# File 'lib/ruby_technical_analysis/indicators/macd.rb', line 6 def fast_period @fast_period end |
#signal_period ⇒ Object (readonly)
Returns the value of attribute signal_period.
6 7 8 |
# File 'lib/ruby_technical_analysis/indicators/macd.rb', line 6 def signal_period @signal_period end |
#slow_period ⇒ Object (readonly)
Returns the value of attribute slow_period.
6 7 8 |
# File 'lib/ruby_technical_analysis/indicators/macd.rb', line 6 def slow_period @slow_period end |
Instance Method Details
#call ⇒ Array
Returns An array containing the current MACD line, signal line, and histogram values.
21 22 23 |
# File 'lib/ruby_technical_analysis/indicators/macd.rb', line 21 def call calculate_macd end |
#valid? ⇒ Boolean
Returns Whether or not the object is valid.
26 27 28 |
# File 'lib/ruby_technical_analysis/indicators/macd.rb', line 26 def valid? series.length >= slow_period + signal_period end |