Location: PHPKode > projects > Finasystem > fs_ta/gd.php
* Finasystem version 0.4 Lin Hai - Technical Analysis Library in PHP
 *Release: 14/10/2006
 *Copyright (C) 2006 Rudy Zuck
 *This program is free software; you can redistribute it and/or
 *modify it under the terms of the GNU General Public License
 *as published by the Free Software Foundation; either version 2
 *of the License, or any later version.
 *This program is distributed in the hope that it will be useful,
 *but WITHOUT ANY WARRANTY; without even the implied warranty of
 *GNU General Public License for more details.
 *You should have received a copy of the GNU General Public License
 *along with this program; if not, write to the Free Software
 *Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA  

 * Generalized DEMA (GD)
 *<p>The GD is a type of moving average, or smoothing function. It is based on the DEMA. The GD takes the DEMA calculation and adds *a vfactor which is between zero and 1. The resultant function is called the GD, or Generalized DEMA. A GD with vfactorof 1 is the *same as the DEMA. A GD with a vfactor of zero is the same as an Exponential Moving Average. The GD typically uses a vfactor of *0.7.</p>
 *<p>The GD was developed by Tim Tillson and was described in his January, 1998 article in Technical Analysis of Stocks &       
 *Commodities magazine. </p>
 * - GD = (1+vfactor) * EMA(input) - EMA(EMA(input))*vfactor
 * @author Rudy Zuck <rudy[-at-]zuck.fr>
 * @copyright Copyright, 2006, Rudy Zuck
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 * @version 0.4
 * @package fs_ta

class gd{
	 * @var double[]
	private $gd;
    * @param double[] $data 
    * @param int $range
	* @param double $vfactor
	* @return double[]
	function get($data,$range,$vfactor){
		$size_data = count($data);
		$my_ema = new ema();
		$ema = $my_ema->get($data,$range);
		$my_ema_ema = new ema();
		$ema_ema = $my_ema_ema->get($ema,$range);
			$this->gd[$i] = $ema[$i]*(1+$vfactor) - $ema_ema[$i]*$vfactor;
		return $this->gd; 

Return current item: Finasystem