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
- #period ⇒ Object
- #slow_limit ⇒ Object
Methods inherited from Indicator
#<<, #[], #dc_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, #size, #t, #ticks, #values
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
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/quant/indicators/mesa.rb', line 66 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
79 80 81 82 83 |
# File 'lib/quant/indicators/mesa.rb', line 79 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
52 53 54 |
# File 'lib/quant/indicators/mesa.rb', line 52 def current_dominant_cycle homodyne_dominant_cycle.points[t0] end |
#delta_phase ⇒ Object
56 57 58 |
# File 'lib/quant/indicators/mesa.rb', line 56 def delta_phase current_dominant_cycle.delta_phase end |
#fast_limit ⇒ Object
40 41 42 |
# File 'lib/quant/indicators/mesa.rb', line 40 def fast_limit @fast_limit ||= (min_period / 2) end |
#homodyne_dominant_cycle ⇒ Object
48 49 50 |
# File 'lib/quant/indicators/mesa.rb', line 48 def homodyne_dominant_cycle series.indicators[source].dominant_cycles.homodyne end |
#period ⇒ Object
36 37 38 |
# File 'lib/quant/indicators/mesa.rb', line 36 def period dc_period end |
#slow_limit ⇒ Object
44 45 46 |
# File 'lib/quant/indicators/mesa.rb', line 44 def slow_limit @slow_limit ||= (max_period) end |