Moving Averages
Exponential
Description
An exponential moving average (EMA) is a type of moving average (MA) that places a greater weight and significance on the most recent data points. The exponential moving average is also referred to as the exponentially weighted moving average. An exponentially weighted moving average reacts more significantly to recent price changes than a simple moving average (SMA), which applies an equal weight to all observations in the period.
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 20 #ema @return [Float] The current EMA value #valid? @return [Boolean] Whether or not the object is valid
Example
require 'ruby-technical-analysis' series = [25, 24.875, 24.781, 24.594, 24.5] period = 5 moving_averages = RubyTechnicalAnalysis::MovingAverages.new( series: series, period: period ) p moving_averages.valid? # true p moving_averages.ema.round(3) # 24.698