Class: Quant::Indicators::Roofing
- Defined in:
- lib/quant/indicators/roofing.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
//Highpass filter cyclic components whose periods are shorter than 48 bars alpha1 = (Cosine(.707*360 / HPPeriod) + Sine (.707*360 / HPPeriod) - 1) / Cosine(.707*360 / HPPeriod); HP = (1 - alpha1 / 2)*(1 - alpha1 / 2)*(Close - 2*Close + Close) + 2*(1 - alpha1)*HP - (1 - alpha1)* (1 - alpha1)*HP; //Smooth with a Super Smoother Filter from equation 3-3 a1 = expvalue(-1.414*3.14159 / LPPeriod); b1 = 2*a1*Cosine(1.414*180 / LPPeriod); c2 = b1; c3 = -a1*a1; c1 = 1 - c2 - c3; Filt = c1*(HP + HP) / 2 + c2*Filt + c3*Filt[2.
- #high_pass_period ⇒ Object
- #low_pass_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, #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
//Highpass filter cyclic components whose periods are shorter than 48 bars alpha1 = (Cosine(.707*360 / HPPeriod) + Sine (.707*360 / HPPeriod) - 1) / Cosine(.707*360 / HPPeriod); HP = (1 - alpha1 / 2)*(1 - alpha1 / 2)*(Close - 2*Close + Close) + 2*(1 - alpha1)*HP - (1 - alpha1)* (1 - alpha1)*HP; //Smooth with a Super Smoother Filter from equation 3-3 a1 = expvalue(-1.414*3.14159 / LPPeriod); b1 = 2*a1*Cosine(1.414*180 / LPPeriod); c2 = b1; c3 = -a1*a1; c1 = 1 - c2 - c3; Filt = c1*(HP + HP) / 2 + c2*Filt + c3*Filt[2
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/quant/indicators/roofing.rb', line 39 def compute a = Math.cos(0.707 * deg2rad(360) / high_pass_period) b = Math.sin(0.707 * deg2rad(360) / high_pass_period) alpha1 = (a + b - 1) / a p0.hp = (1 - alpha1 / 2)**2 * (p0.input - 2 * p1.input + p2.input) + 2 * (1 - alpha1) * p1.hp - (1 - alpha1)**2 * p2.hp a1 = Math.exp(-1.414 * Math::PI / low_pass_period) c2 = 2 * a1 * Math.cos(1.414 * deg2rad(180) / low_pass_period) c3 = -a1**2 c1 = 1 - c2 - c3 p0.value = c1 * (p0.hp + p1.hp) / 2 + c2 * p1.value + c3 * p2.value p0.direction = p0.value > p2.value ? 1 : -1 p0.turned = p0.direction != p2.direction # Peak = .991 * Peak[1]; # If AbsValue(BP) > Peak Then Peak = AbsValue(BP); If Peak <> 0 Then Signal = BP / Peak; p0.peak = [p0.value.abs, 0.991 * p1.peak].max p0.agc = p0.peak == 0 ? 0 : p0.value / p0.peak end |
#high_pass_period ⇒ Object
24 25 26 |
# File 'lib/quant/indicators/roofing.rb', line 24 def high_pass_period low_pass_period * 2 end |
#low_pass_period ⇒ Object
20 21 22 |
# File 'lib/quant/indicators/roofing.rb', line 20 def low_pass_period dc_period end |