Class: Quant::Indicators::Decycler
- Defined in:
- lib/quant/indicators/decycler.rb
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
- #compute ⇒ Object
- #compute_agc ⇒ Object
- #compute_decycler ⇒ Object
-
#compute_hp(period, hp) ⇒ Object
alpha1 = (Cosine(.707*360 / HPPeriod1) + Sine (.707*360 / HPPeriod1) - 1) / Cosine(.707*360 / HPPeriod1); HP1 = (1 - alpha1 / 2)*(1 - alpha1 / 2)*(Close - 2*Close + Close) + 2*(1 - alpha1)*HP1 - (1 - alpha1)*(1 - alpha1)*HP1;.
- #compute_ift ⇒ Object
- #compute_oscillator ⇒ Object
- #max_period ⇒ Object
- #min_period ⇒ Object
Methods inherited from Indicator
#<<, #[], #dc_period, #dominant_cycle, #dominant_cycle_kind, #each, #half_period, #indicator_name, #initialize, #input, #inspect, #micro_period, #p, #period_points, #pivot_kind, #points_class, #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
77 78 79 80 81 82 |
# File 'lib/quant/indicators/decycler.rb', line 77 def compute compute_decycler compute_oscillator compute_agc compute_ift end |
#compute_agc ⇒ Object
68 69 70 71 |
# File 'lib/quant/indicators/decycler.rb', line 68 def compute_agc p0.peak = [p0.osc.abs, 0.991 * p1.peak].max p0.agc = p0.peak.zero? ? p0.osc : p0.osc / p0.peak end |
#compute_decycler ⇒ Object
47 48 49 50 |
# File 'lib/quant/indicators/decycler.rb', line 47 def compute_decycler alpha = period_to_alpha(max_period) p0.decycle = (alpha / 2) * (p0.oc2 + p1.oc2) + (1.0 - alpha) * p1.decycle end |
#compute_hp(period, hp) ⇒ Object
alpha1 = (Cosine(.707*360 / HPPeriod1) + Sine (.707*360 / HPPeriod1) - 1) / Cosine(.707*360 / HPPeriod1); HP1 = (1 - alpha1 / 2)*(1 - alpha1 / 2)*(Close - 2*Close + Close) + 2*(1 - alpha1)*HP1 - (1 - alpha1)*(1 - alpha1)*HP1;
54 55 56 57 58 59 60 |
# File 'lib/quant/indicators/decycler.rb', line 54 def compute_hp(period, hp) radians = deg2rad(360) c = Math.cos(0.707 * radians / period) s = Math.sin(0.707 * radians / period) alpha = (c + s - 1) / c (1 - alpha / 2)**2 * (p0.oc2 - 2 * p1.oc2 + p2.oc2) + 2 * (1 - alpha) * p1.send(hp) - (1 - alpha) * (1 - alpha) * p2.send(hp) end |
#compute_ift ⇒ Object
73 74 75 |
# File 'lib/quant/indicators/decycler.rb', line 73 def compute_ift p0.ift = ift(p0.agc, 5.0) end |
#compute_oscillator ⇒ Object
62 63 64 65 66 |
# File 'lib/quant/indicators/decycler.rb', line 62 def compute_oscillator p0.hp1 = compute_hp(min_period, :hp1) p0.hp2 = compute_hp(max_period, :hp2) p0.osc = p0.hp2 - p0.hp1 end |
#max_period ⇒ Object
39 40 41 |
# File 'lib/quant/indicators/decycler.rb', line 39 def max_period dc_period end |
#min_period ⇒ Object
43 44 45 |
# File 'lib/quant/indicators/decycler.rb', line 43 def min_period settings.min_period end |