Moving Averages
Weighted
Description
Over the years, technicians have found two problems with the simple moving average. The first problem lies in the time frame of the moving average (MA). Most technical analysts believe that price action, the opening or closing stock price, is not enough on which to depend for properly predicting buy or sell signals of the MA's crossover action. To solve this problem, analysts now assign more weight to the most recent price data by using the exponentially smoothed moving average (EMA).
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 #wma @return [Float] The current WMA 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.wma.round(3) # 24.665