Module: TechnicalAnalysis::Momentum
- Defined in:
- lib/technical_analysis/lane.rb,
lib/technical_analysis/momentum/rsi.rb,
lib/technical_analysis/momentum/tsi.rb,
lib/technical_analysis/momentum/lane-stochastic.rb
Defined Under Namespace
Classes: LANE, Lane, RSI, Rsi, TSI, Tsi
Constant Summary collapse
- LaneStochastic =
set alias for the class
Lane
Class Method Summary collapse
-
.tsi(current_value, tsi_source, low_period = 13, high_period = 25) ⇒ Object
z = Symbols::Futures.mini_dax.eod( duration: '30 d').each e= nil ema= z.map{|y| e= TechnicalAnalysis::MovingAverage.ema( y.close, z.map(&:close), 30, e ) }.
Class Method Details
.tsi(current_value, tsi_source, low_period = 13, high_period = 25) ⇒ Object
z = Symbols::Futures.mini_dax.eod( duration: '30 d').each e= nil ema= z.map{|y| e= TechnicalAnalysis::MovingAverage.ema( y.close, z.map(&:close), 30, e ) }
or
EMA = Struct.new :time, :ema e = nil ema = z.map do |y| EMA.new y.time, e = TechnicalAnalysis::MovingAverage.ema y.close, z.map(&:close), 30, e end
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/technical_analysis/lane.rb', line 26 def self.tsi current_value, tsi_source, low_period = 13, high_period = 25 if current_value.present? tsi_source.push current_value else current_value = tsi_source.last end momentum = tsi_source[-1] - tsi_source[-2] high_multiplier = (2.0 / (high_period + 1.0)) low_multiplier = (2.0 / (low_period + 1.0)) if prev_tsi.nil? data.sum / data.size.to_f # Average else (current_value - prev_ema) * (2.0 / (period + 1.0)) + prev_ema end end |