Class: IB::Bar

Inherits:
Object
  • Object
show all
Includes:
TechnicalAnalysis::BarCalculation
Defined in:
lib/ib/bar.rb,
lib/calculation_helpers.rb

Instance Method Summary collapse

Instance Method Details

#pivotObject



15
16
17
18
19
20
21
# File 'lib/ib/bar.rb', line 15

def pivot 
  { pp: p=( high + close + low ).to_f / 3 ,
    r1: ( 2 * p ).to_f - low.to_f,
    r2: p + ( high - low ).to_f,
    s1:  ( 2 * p ).to_f - high.to_f,
    s2: p - ( high - low ).to_f }
end

#true_range(previous_close) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/ib/bar.rb', line 3

def true_range previous_close
  [
    (high - low),
    (high - previous_close).abs,
    (low - previous_close).abs
  ].max
end

#typical_priceObject



11
12
13
# File 'lib/ib/bar.rb', line 11

def typical_price
  ( high + low + close ) / 3.0
end