Class: Quant::Indicators::Pivots::Pivot
- Defined in:
- lib/quant/indicators/pivots/pivot.rb
Direct Known Subclasses
Atr, Bollinger, Camarilla, Classic, Demark, Donchian, Fibbonacci, Guppy, Keltner, Murrey, Traditional, Woodie
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
- #band?(band) ⇒ Boolean
- #compute ⇒ Object
- #compute_bands ⇒ Object
- #compute_extents ⇒ Object
- #compute_midpoint ⇒ Object
- #compute_value ⇒ Object
- #period ⇒ Object
- #period_midpoints ⇒ Object
- #points_class ⇒ 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, #priority, register, #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
#averaging_period ⇒ Object
67 68 69 |
# File 'lib/quant/indicators/pivots/pivot.rb', line 67 def averaging_period min_period end |
#band?(band) ⇒ Boolean
59 60 61 |
# File 'lib/quant/indicators/pivots/pivot.rb', line 59 def band?(band) p0.key?(band) end |
#compute ⇒ Object
75 76 77 78 79 80 |
# File 'lib/quant/indicators/pivots/pivot.rb', line 75 def compute compute_extents compute_value compute_midpoint compute_bands end |
#compute_bands ⇒ Object
90 91 92 |
# File 'lib/quant/indicators/pivots/pivot.rb', line 90 def compute_bands # No-op -- override in subclasses end |
#compute_extents ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/quant/indicators/pivots/pivot.rb', line 94 def compute_extents period_midpoints.tap do |midpoints| p0.high_price = t0.high_price p0.low_price = t0.low_price p0.highest = midpoints.max p0.lowest = midpoints.min p0.range = p0.high_price - p0.low_price p0.avg_low = super_smoother(:low_price, previous: :avg_low, period: averaging_period) p0.avg_high = super_smoother(:high_price, previous: :avg_high, period: averaging_period) p0.avg_range = super_smoother(:range, previous: :avg_range, period: averaging_period) end end |
#compute_midpoint ⇒ Object
82 83 84 |
# File 'lib/quant/indicators/pivots/pivot.rb', line 82 def compute_midpoint p0.midpoint = p0.input end |
#compute_value ⇒ Object
86 87 88 |
# File 'lib/quant/indicators/pivots/pivot.rb', line 86 def compute_value # No-op -- override in subclasses end |
#period ⇒ Object
63 64 65 |
# File 'lib/quant/indicators/pivots/pivot.rb', line 63 def period dc_period end |
#period_midpoints ⇒ Object
71 72 73 |
# File 'lib/quant/indicators/pivots/pivot.rb', line 71 def period_midpoints period_points(period).map(&:midpoint) end |
#points_class ⇒ Object
55 56 57 |
# File 'lib/quant/indicators/pivots/pivot.rb', line 55 def points_class Quant::Indicators::Pivots::PivotPoint end |