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
- #smoothed_average_midpoint ⇒ 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, #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
65 66 67 |
# File 'lib/quant/indicators/pivots/pivot.rb', line 65 def averaging_period min_period end |
#band?(band) ⇒ Boolean
57 58 59 |
# File 'lib/quant/indicators/pivots/pivot.rb', line 57 def band?(band) p0.key?(band) end |
#compute ⇒ Object
77 78 79 80 81 82 |
# File 'lib/quant/indicators/pivots/pivot.rb', line 77 def compute compute_extents compute_value compute_midpoint compute_bands end |
#compute_bands ⇒ Object
92 93 94 |
# File 'lib/quant/indicators/pivots/pivot.rb', line 92 def compute_bands # No-op -- override in subclasses end |
#compute_extents ⇒ Object
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/quant/indicators/pivots/pivot.rb', line 96 def compute_extents period_midpoints.tap do |midpoints| p0.highest = midpoints.max p0.lowest = midpoints.min p0.range = p0.high_price - p0.low_price p0.avg_low = three_pole_super_smooth(:low_price, previous: :avg_low, period: averaging_period) p0.avg_high = three_pole_super_smooth(:high_price, previous: :avg_high, period: averaging_period) p0.avg_range = three_pole_super_smooth(:range, previous: :avg_range, period: averaging_period) end end |
#compute_midpoint ⇒ Object
84 85 86 |
# File 'lib/quant/indicators/pivots/pivot.rb', line 84 def compute_midpoint p0.midpoint = p0.input end |
#compute_value ⇒ Object
88 89 90 |
# File 'lib/quant/indicators/pivots/pivot.rb', line 88 def compute_value # No-op -- override in subclasses end |
#period ⇒ Object
61 62 63 |
# File 'lib/quant/indicators/pivots/pivot.rb', line 61 def period adaptive_period end |
#period_midpoints ⇒ Object
69 70 71 |
# File 'lib/quant/indicators/pivots/pivot.rb', line 69 def period_midpoints period_points(period).map(&:midpoint) end |
#points_class ⇒ Object
53 54 55 |
# File 'lib/quant/indicators/pivots/pivot.rb', line 53 def points_class Quant::Indicators::Pivots::PivotPoint end |
#smoothed_average_midpoint ⇒ Object
73 74 75 |
# File 'lib/quant/indicators/pivots/pivot.rb', line 73 def smoothed_average_midpoint three_pole_super_smooth :input, previous: :midpoint, period: averaging_period end |