Class: Quant::Indicators::Decycler
- Defined in:
- lib/quant/indicators/decycler.rb
Constant Summary
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_automatic_gain_control ⇒ Object
AGC is constrained to -1.0 to 1.0 The peak decays at a rate of 0.991 per bar.
- #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_inverse_fisher_transform ⇒ Object
- #compute_oscillator ⇒ Object
- #max_period ⇒ 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, #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 |
# File 'lib/quant/indicators/decycler.rb', line 65 def compute compute_decycler compute_oscillator compute_automatic_gain_control compute_inverse_fisher_transform end |
#compute_automatic_gain_control ⇒ Object
AGC is constrained to -1.0 to 1.0 The peak decays at a rate of 0.991 per bar
56 57 58 59 |
# File 'lib/quant/indicators/decycler.rb', line 56 def compute_automatic_gain_control 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
33 34 35 36 |
# File 'lib/quant/indicators/decycler.rb', line 33 def compute_decycler alpha = period_to_alpha(max_period) p0.decycle = (alpha / 2) * (p0.input + p1.input) + (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;
40 41 42 43 44 45 46 |
# File 'lib/quant/indicators/decycler.rb', line 40 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.input - 2 * p1.input + p2.input) + 2 * (1 - alpha) * p1.send(hp) - (1 - alpha) * (1 - alpha) * p2.send(hp) end |
#compute_inverse_fisher_transform ⇒ Object
61 62 63 |
# File 'lib/quant/indicators/decycler.rb', line 61 def compute_inverse_fisher_transform p0.ift = inverse_fisher_transform(p0.agc, scale_factor: 5.0) end |
#compute_oscillator ⇒ Object
48 49 50 51 52 |
# File 'lib/quant/indicators/decycler.rb', line 48 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
29 30 31 |
# File 'lib/quant/indicators/decycler.rb', line 29 def max_period dc_period end |