Class: Quant::Indicators::Ma
- Includes:
- Mixins::Filters
- Defined in:
- lib/quant/indicators/ma.rb
Overview
Moving Averages
Constant Summary
Constants included from Mixins::UniversalFilters
Instance Attribute Summary
Attributes inherited from Indicator
#p0, #p1, #p2, #p3, #series, #source, #t0, #t1, #t2, #t3
Instance Method Summary collapse
Methods included from Mixins::UniversalFilters
#universal_band_pass, #universal_ema, #universal_filter, #universal_one_pole_high_pass, #universal_one_pole_low_pass, #universal_two_pole_high_pass, #universal_two_pole_low_pass
Methods included from Mixins::ButterworthFilters
#three_pole_butterworth, #two_pole_butterworth
Methods included from Mixins::HighPassFilters
#high_pass_filter, #two_pole_high_pass_filter
Methods inherited from Indicator
#<<, #[], #each, #indicator_name, #initialize, #input, #inspect, #p, #points_class, #size, #t, #ticks, #values
Methods included from Mixins::ExponentialMovingAverage
Methods included from Mixins::SimpleMovingAverage
Methods included from Mixins::WeightedMovingAverage
#extended_weighted_moving_average, #weighted_moving_average
Methods included from Mixins::Functions
#angle, #bars_to_alpha, #deg2rad, #period_to_alpha, #rad2deg
Constructor Details
This class inherits a constructor from Quant::Indicators::Indicator
Instance Method Details
#alpha(period) ⇒ Object
21 22 23 |
# File 'lib/quant/indicators/ma.rb', line 21 def alpha(period) (period) end |
#compute ⇒ Object
33 34 35 36 37 |
# File 'lib/quant/indicators/ma.rb', line 33 def compute # p0.ss = super_smoother input, :ss, min_period p0.ema = alpha(max_period) * input + (1 - alpha(max_period)) * p1.ema p0.osc = p0.ss - p0.ema end |
#max_period ⇒ Object
29 30 31 |
# File 'lib/quant/indicators/ma.rb', line 29 def max_period 48 # Quant.config.indicators.max_period end |
#min_period ⇒ Object
25 26 27 |
# File 'lib/quant/indicators/ma.rb', line 25 def min_period 8 # Quant.config.indicators.min_period end |