Class: Quant::Indicators::Pivots::Demark
- Defined in:
- lib/quant/indicators/pivots/demark.rb
Overview
R1 = X / 2 - L PP = X / 4 (this is not an official DeMark number but merely a reference point based on the calculation of X) S1 = X / 2 - H
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
- #averaging_period ⇒ Object
- #compute_bands ⇒ Object
- #compute_midpoint ⇒ Object
- #compute_value ⇒ Object
- #x_factor ⇒ Object
Methods inherited from Pivot
#band?, #compute, #compute_extents, #period, #period_midpoints, #points_class, #smoothed_average_midpoint
Methods inherited from Indicator
#<<, #[], #adaptive_half_period, #adaptive_period, #compute, 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
#averaging_period ⇒ Object
19 20 21 |
# File 'lib/quant/indicators/pivots/demark.rb', line 19 def averaging_period min_period / 2 end |
#compute_bands ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/quant/indicators/pivots/demark.rb', line 42 def compute_bands p0.h1 = (p0.input / 2.0) - p0.avg_high p0.h1 = three_pole_super_smooth :h1, previous: :h1, period: averaging_period p0.l1 = (p0.input / 2.0) - p0.avg_low p0.l1 = three_pole_super_smooth :l1, previous: :l1, period: averaging_period end |
#compute_midpoint ⇒ Object
37 38 39 40 |
# File 'lib/quant/indicators/pivots/demark.rb', line 37 def compute_midpoint p0.midpoint = p0.input / 4.0 p0.midpoint = three_pole_super_smooth :midpoint, previous: :midpoint, period: averaging_period end |
#compute_value ⇒ Object
33 34 35 |
# File 'lib/quant/indicators/pivots/demark.rb', line 33 def compute_value p0.input = x_factor end |
#x_factor ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/quant/indicators/pivots/demark.rb', line 23 def x_factor if t0.close_price == t0.open_price ((2.0 * t0.close_price) + p0.avg_high + p0.avg_low) elsif t0.close_price > t0.open_price ((2.0 * p0.avg_high) + p0.avg_low + t0.close_price) else ((2.0 * p0.avg_low) + p0.avg_high + t0.close_price) end end |