Indicators

Price Channel


Description

The term price channel refers to a signal that appears on a chart when a security's price becomes bounded between two parallel lines. The price channel may be termed horizontal, ascending, or descending depending on the direction of the trend. Price channels are often used by traders who practice the art of technical analysis to gauge the momentum and direction of a security's price action and to identify trading channels.

For more information, please visit Investopedia.


Params & Instance Methods

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

#call
@return [Array] An array containing the current upper and lower price channel values

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

Example

require 'ruby-technical-analysis'

series = [[2.8097, 2.8437], [2.9063, 2.8543], [2.875, 2.8333],
          [2.8543, 2.8127], [2.974, 2.8647], [3.073, 2.9793]]
period = 5

price_channel = 
  RubyTechnicalAnalysis::PriceChannel.new(
    series: series,
    period: period
  )

p price_channel.valid? # true

p price_channel.call # [2.974, 2.8127]