Class: RubyTechnicalAnalysis::StochasticOscillator
- Defined in:
- lib/ruby_technical_analysis/indicators/stochastic_oscillator.rb
Overview
Stochastic Oscillator
Find more information at: www.investopedia.com/terms/s/stochasticoscillator.asp
Instance Attribute Summary collapse
-
#d_periods ⇒ Object
readonly
Returns the value of attribute d_periods.
-
#k_periods ⇒ Object
readonly
Returns the value of attribute k_periods.
-
#k_slow_periods ⇒ Object
readonly
Returns the value of attribute k_slow_periods.
Attributes inherited from Indicator
Instance Method Summary collapse
-
#call ⇒ Float
The current Stochastic Oscillator value.
-
#initialize(series: [], k_periods: 14, k_slow_periods: 3, d_periods: 3) ⇒ StochasticOscillator
constructor
A new instance of StochasticOscillator.
-
#valid? ⇒ Boolean
Whether or not the object is valid.
Methods inherited from Indicator
Constructor Details
#initialize(series: [], k_periods: 14, k_slow_periods: 3, d_periods: 3) ⇒ StochasticOscillator
Returns a new instance of StochasticOscillator.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ruby_technical_analysis/indicators/stochastic_oscillator.rb', line 12 def initialize(series: [], k_periods: 14, k_slow_periods: 3, d_periods: 3) @k_periods = k_periods @k_slow_periods = k_slow_periods @d_periods = d_periods @lowest_lows = [] @highest_highs = [] @close_minus_lowest_lows = [] @highest_highs_minus_lowest_lows = [] @ks_sums_close_minus_lowest_lows = [] @ks_sums_highest_highs_minus_lowest_lows = [] @ks_sums_quotients_times_one_hundred = [] @d_periods_sma = [] super(series: series) end |
Instance Attribute Details
#d_periods ⇒ Object (readonly)
Returns the value of attribute d_periods.
6 7 8 |
# File 'lib/ruby_technical_analysis/indicators/stochastic_oscillator.rb', line 6 def d_periods @d_periods end |
#k_periods ⇒ Object (readonly)
Returns the value of attribute k_periods.
6 7 8 |
# File 'lib/ruby_technical_analysis/indicators/stochastic_oscillator.rb', line 6 def k_periods @k_periods end |
#k_slow_periods ⇒ Object (readonly)
Returns the value of attribute k_slow_periods.
6 7 8 |
# File 'lib/ruby_technical_analysis/indicators/stochastic_oscillator.rb', line 6 def k_slow_periods @k_slow_periods end |
Instance Method Details
#call ⇒ Float
Returns The current Stochastic Oscillator value.
29 30 31 |
# File 'lib/ruby_technical_analysis/indicators/stochastic_oscillator.rb', line 29 def call calculate_stochastic_oscillator end |
#valid? ⇒ Boolean
Returns Whether or not the object is valid.
34 35 36 |
# File 'lib/ruby_technical_analysis/indicators/stochastic_oscillator.rb', line 34 def valid? k_periods + d_periods <= series.length end |