Indicators

Volume Oscillator


Description

The Volume Oscillator (VO) works on the technical premise that it is not the actual level of volume, but the change in volume relative to the recent past that has more technical significance. The Volume Oscillator displays the difference between two moving averages of a security's volume expressed as a percentage.

For more information, please visit Fidelity.


Params & Instance Methods

#initialize
@param series [Array] An array of volume values
@param short_ma_period [Integer] The number of periods to use in the calculation of the short moving average - default is 20
@param long_ma_period [Integer] The number of periods to use in the calculation of the long moving average - default is 60

#call
@return [Float] The current volume oscillator value

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

Example

require 'ruby-technical-analysis'

series = [17_604, 18_918, 21_030, 13_854, 10_866]
short_ma_period = 2
long_ma_period = 5

volume_oscillator = 
  RubyTechnicalAnalysis::VolumeOscillator.new(
    series: series,
    short_ma_period: short_ma_period,
    long_ma_period: long_ma_period
  )

p volume_oscillator.valid? # true

p volume_oscillator.call # -24.88