Sha256: 359cad89da7d5ab12c4e854355660998b2549e1e3d1e59869e7fcff5f085541c
Contents?: true
Size: 684 Bytes
Versions: 20
Compression:
Stored size: 684 Bytes
Contents
# lib/sqa/indicator/moving_average_convergence_divergence.rb class SQA::Indicator; class << self def moving_average_convergence_divergence( prices, short_period, long_period, signal_period ) short_ma = simple_moving_average(prices, short_period) long_ma = simple_moving_average(prices, long_period) signal_line = simple_moving_average(short_ma, signal_period) macd_line = [] prices.size.times do |x| macd_line << short_ma[x] - long_ma[x] end { macd: macd_line, # Array signal: signal_line # Array } end alias_method :macd, :moving_average_convergence_divergence end; end
Version data entries
20 entries across 20 versions & 1 rubygems