/** * @return float */ private function getAtrSum() : float { $highs = []; $lows = []; $closes = []; foreach ($this->data_with_extra_period as $row) { $highs[] = $row->high; $lows[] = $row->low; $closes[] = $row->close; } $atrs = trader_atr($highs, $lows, $closes, 1); // ATR (1 period) $sum = 0; foreach ($atrs as $atr) { $sum += $atr; } return $sum; }
/** * @return float */ private function getAtrSum() { $highs = []; $lows = []; $closes = []; foreach ($this->data_with_extra_period as $row) { $highs[] = $row->high; $lows[] = $row->low; $closes[] = $row->close; } // trader_atr requires PECL trader >= 0.2.0 to be installed - See http://php.net/manual/en/trader.installation.php $atrs = trader_atr($highs, $lows, $closes, 1); // ATR (1 period) $sum = 0; foreach ($atrs as $atr) { $sum += $atr; } return $sum; }