Indicators

Williams %R


Description

Williams %R, also known as the Williams Percent Range, is a type of momentum indicator that moves between 0 and -100 and measures overbought and oversold levels. The Williams %R may be used to find entry and exit points in the market. The indicator is very similar to the Stochastic oscillator and is used in the same way. It was developed by Larry Williams and it compares a stock’s closing price to the high-low range over a specific period, typically 14 days or periods.

For more information, please visit Investopedia.


Params & Instance Methods

#initialize
@param series [Array] An array of arrays containing high, low, close prices, e.g. [[high, low, close], [high, low, close]]
@param period [Integer] The number of periods to use in the calculation - default is 14

#call
@return [Float] The current Williams %R value

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

Example

require 'ruby-technical-analysis'

series = [[631.34, 624.81, 626.01], [627.11, 623.59, 626.44], [628.49, 621.33, 622.2],
          [630.89, 622.2, 630.8], [632.85, 630.21, 632.85], [633.26, 629.64, 633.06]]
period = 5

williams_percent_r = 
  RubyTechnicalAnalysis::WilliamsPercentR.new(
    series: series,
    period: period
  )

p williams_percent_r.valid? # true

p williams_percent_r.call # -1.68