Location: PHPKode > projects > Finasystem > fs_ta/avgprice.php
<?php
/**
* Finasystem version 0.4 Lin Hai - Technical Analysis Library in PHP
 *Release: 14/10/2006
 *Copyright (C) 2006 Rudy Zuck
 *mailto:rudy[-at-]zuck.fr
 *web:http://sourceforge.net/projects/finasystem
 *
 *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
 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *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  
 */

/**
 * Average Price (avgprice)
 *
 *<p>The Average Price is the average of the open + high + low + close of a bar. It can be 
 *used to smooth an indicator that normally takes just the closing price as input.</p>
 *
 *<p>Formula:</p>
 *
 * - avgprice= (open+high+low+close)/4
 *
 * @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 avgprice{
	
	/**
	 * @var double[]
	 */
	private $avgprice;
	
	/**
	 * @param double[] $open
	 * @param double[] $high
	 * @param double[] $low
	 * @param double[] $close
	 * @return double[]
     */
	function get($open,$high,$low,$close){
		$size_data = count($close);	
		for ($i=0;$i<$size_data;$i++){
			$this->avgprice[$i] = ($open[$i] + $high[$i] + $low[$i] + $close[$i])/4;
		}
		return $this->avgprice;
	}	
}
?>
Return current item: Finasystem