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

Version Path
sqa-0.0.24 lib/sqa/indicator/moving_average_convergence_divergence.rb
sqa-0.0.22 lib/sqa/indicator/moving_average_convergence_divergence.rb
sqa-0.0.21 lib/sqa/indicator/moving_average_convergence_divergence.rb
sqa-0.0.20 lib/sqa/indicator/moving_average_convergence_divergence.rb
sqa-0.0.19 lib/sqa/indicator/moving_average_convergence_divergence.rb
sqa-0.0.18 lib/sqa/indicator/moving_average_convergence_divergence.rb
sqa-0.0.17 lib/sqa/indicator/moving_average_convergence_divergence.rb
sqa-0.0.15 lib/sqa/indicator/moving_average_convergence_divergence.rb
sqa-0.0.14 lib/sqa/indicator/moving_average_convergence_divergence.rb
sqa-0.0.13 lib/sqa/indicator/moving_average_convergence_divergence.rb
sqa-0.0.12 lib/sqa/indicator/moving_average_convergence_divergence.rb
sqa-0.0.11 lib/sqa/indicator/moving_average_convergence_divergence.rb
sqa-0.0.10 lib/sqa/indicator/moving_average_convergence_divergence.rb
sqa-0.0.9 lib/sqa/indicator/moving_average_convergence_divergence.rb
sqa-0.0.8 lib/sqa/indicator/moving_average_convergence_divergence.rb
sqa-0.0.7 lib/sqa/indicator/moving_average_convergence_divergence.rb
sqa-0.0.6 lib/sqa/indicator/moving_average_convergence_divergence.rb
sqa-0.0.5 lib/sqa/indicator/moving_average_convergence_divergence.rb
sqa-0.0.4 lib/sqa/indicator/moving_average_convergence_divergence.rb
sqa-0.0.3 lib/sqa/indicator/moving_average_convergence_divergence.rb