Module: PivotPoints

Included in:
Array
Defined in:
lib/ruby-technical-analysis/indicators/pivot_points.rb

Overview

Pivot Points indicator Returns an array of the current pivot points for the provided H, L, C array

Instance Method Summary collapse

Instance Method Details

#pivot_pointsObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ruby-technical-analysis/indicators/pivot_points.rb', line 6

def pivot_points
  h = at(0)
  l = at(1)
  c = at(2)
  pp = ((h + l + c) / 3.0).round(2)
  r1 = ((pp * 2) - l).round(2)
  s1 = ((pp * 2) - h).round(2)
  r2 = (pp + (h - l)).round(2)
  s2 = (pp - (h - l)).round(2)
  r3 = (h + (2 * (pp - l))).round(2)
  s3 = (l - (2 * (h - pp))).round(2)
  [s3, s2, s1, pp, r1, r2, r3]
end