<?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
*/
/**
* Momentum (mom)
*
*<p>Momentum monitors the change in prices. It tells you whether prices are increasing
*at an increasing rate or decreasing at a decreasing rate. Is the market trend about
*to change? Is the market overbought or oversold? Momentum may help you find those
*market conditions.</p>
*
*<p>Formula:</p>
*
* - Momentum = P(t) - P(t-n)
*
* @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 mom{
/**
* @var double[]
*/
private $mom;
/**
* @param double[] $data
* @param int $range
* @param int $range
* @return double
*/
function get($data,$range){
$size_data = count($data);
for ($i=$range-1; $i<$size_data;$i++){
$this->mom[$i]=$data[$i] - $data[$i-$range+1] ;
}
return $this->mom;
}
}
?>