Indicators

Rate of Change


Description

The Rate of Change (ROC) is the speed at which a variable changes over a specific period of time. ROC is often used when speaking about momentum, and it can generally be expressed as a ratio between a change in one variable relative to a corresponding change in another; graphically, the rate of change is represented by the slope of a line. The ROC is often illustrated by the Greek letter delta.

For more information, please visit Investopedia.


Params & Instance Methods

#initialize
@param series [Array] An array of prices, typically closing prices
@param period [Integer] The number of periods to use in the calculation - default is 30

#call
@return [Float] The current ROC value

#valid?
@return [Boolean] Whether or not the object is valid

Example

require 'ruby-technical-analysis'

series = [5.5625, 5.375, 5.375, 5.0625]
period = 3

rate_of_change = 
  RubyTechnicalAnalysis::RateOfChange.new(
    series: series,
    period: period
  )

p rate_of_change.valid? # true

p rate_of_change.call # -8.99
Previous
QStick