Class: Quant::Indicators::Mesa
- Defined in:
- lib/quant/indicators/mesa.rb
Overview
www.mesasoftware.com/papers/MAMA.pdf MESA Adaptive Moving Average (MAMA) adapts to price movement in an entirely new and unique way. The adapation is based on the rate change of phase as measured by the Hilbert Transform Discriminator.
This version of Ehler’s MAMA indicator ties into the homodyne dominant cycle indicator to provide a more efficient computation for this indicator. If you’re using the homodyne in all your indicators for the dominant cycle, then this version is useful as it avoids extra computational steps.
Constant Summary collapse
- FAMA =
0.500
- GAMA =
0.950
- DAMA =
0.125
- LAMA =
0.100
- FAGA =
0.050
Constants inherited from Indicator
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
- #compute ⇒ Object
- #compute_oscillator ⇒ Object
- #current_dominant_cycle ⇒ Object
- #delta_phase ⇒ Object
- #fast_limit ⇒ Object
- #homodyne_dominant_cycle ⇒ Object
- #slow_limit ⇒ Object
Methods inherited from Indicator
#<<, #[], #adaptive_half_period, #adaptive_period, dependent_indicator_classes, depends_on, #dominant_cycle, #dominant_cycle_indicator_class, #dominant_cycle_kind, #each, #half_period, #indicator_name, #initialize, #input, #inspect, #max_period, #micro_period, #min_period, #p, #period_points, #pivot_kind, #points_class, #priority, register, #size, #t, #ticks, #values, #warmed_up?
Methods included from Mixins::FisherTransform
#fisher_transform, #inverse_fisher_transform, #relative_fisher_transform
Methods included from Mixins::Stochastic
Methods included from Mixins::SuperSmoother
#three_pole_super_smooth, #two_pole_super_smooth
Methods included from Mixins::HilbertTransform
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::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, #hpf2, #two_pole_high_pass_filter
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
#compute ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/quant/indicators/mesa.rb', line 65 def compute alpha = [fast_limit / delta_phase, slow_limit].max p0.mama = (alpha * p0.input) + ((1.0 - alpha) * p1.mama) p0.fama = (FAMA * alpha * p0.mama) + ((1.0 - (FAMA * alpha)) * p1.fama) p0.gama = (GAMA * alpha * p0.mama) + ((1.0 - (GAMA * alpha)) * p1.gama) p0.dama = (DAMA * alpha * p0.mama) + ((1.0 - (DAMA * alpha)) * p1.dama) p0.lama = (LAMA * alpha * p0.mama) + ((1.0 - (LAMA * alpha)) * p1.lama) p0.faga = (FAGA * alpha * p0.fama) + ((1.0 - (FAGA * alpha)) * p1.faga) compute_oscillator end |
#compute_oscillator ⇒ Object
78 79 80 81 82 |
# File 'lib/quant/indicators/mesa.rb', line 78 def compute_oscillator p0.osc = p0.mama - p0.fama p0.crossed = :up if p0.osc >= 0 && p1.osc < 0 p0.crossed = :down if p0.osc <= 0 && p1.osc > 0 end |
#current_dominant_cycle ⇒ Object
51 52 53 |
# File 'lib/quant/indicators/mesa.rb', line 51 def current_dominant_cycle homodyne_dominant_cycle.points[t0] end |
#delta_phase ⇒ Object
55 56 57 |
# File 'lib/quant/indicators/mesa.rb', line 55 def delta_phase current_dominant_cycle.delta_phase end |
#fast_limit ⇒ Object
39 40 41 |
# File 'lib/quant/indicators/mesa.rb', line 39 def fast_limit @fast_limit ||= (micro_period) end |
#homodyne_dominant_cycle ⇒ Object
47 48 49 |
# File 'lib/quant/indicators/mesa.rb', line 47 def homodyne_dominant_cycle series.indicators[source].dominant_cycles.homodyne end |
#slow_limit ⇒ Object
43 44 45 |
# File 'lib/quant/indicators/mesa.rb', line 43 def slow_limit @slow_limit ||= (max_period) end |