Method: TechnicalAnalysis::StockCalculation.ema
- Defined in:
- lib/technical_analysis/helpers/stock_calculation.rb
.ema(current_value, data, period, prev_value) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/technical_analysis/helpers/stock_calculation.rb', line 16 def self.ema(current_value, data, period, prev_value) if prev_value.nil? ArrayHelper.average(data) else (current_value - prev_value) * (2.0 / (period + 1.0)) + prev_value end end |