Class: Quant::Indicators::RocketRsi
- Defined in:
- lib/quant/indicators/rocket_rsi.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
Methods inherited from Indicator
#<<, #[], #adaptive_half_period, #adaptive_period, dependent_indicator_classes, depends_on, #dominant_cycle, #dominant_cycle_indicator_class, #dominant_cycle_kind, #each, #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
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/quant/indicators/rocket_rsi.rb', line 32 def compute p0.hp = two_pole_butterworth :input, previous: :hp, period: quarter_period lp = p(half_period) p0.delta = p0.hp - lp.hp p0.delta > 0.0 ? p0.gain = p0.delta : p0.loss = p0.delta.abs period_points(half_period).tap do |period_points| p0.gains = period_points.map(&:gain).sum p0.losses = period_points.map(&:loss).sum end p0.denom = p0.gains + p0.losses if p0.denom.zero? p0.inst_rsi = p1.inst_rsi p0.rsi = p1.rsi else p0.inst_rsi = ((p0.gains - p0.losses) / p0.denom) p0.rsi = fisher_transform(p0.inst_rsi).clamp(-1.0, 1.0) end p0.crosses = (p0.rsi >= 0.0 && p1.rsi < 0.0) || (p0.rsi <= 0.0 && p1.rsi > 0.0) end |
#half_period ⇒ Object
28 29 30 |
# File 'lib/quant/indicators/rocket_rsi.rb', line 28 def half_period (dc_period / 2) - 1 end |
#quarter_period ⇒ Object
24 25 26 |
# File 'lib/quant/indicators/rocket_rsi.rb', line 24 def quarter_period half_period / 2 end |