note 114290 added to function.trader-ema
| From: | manoj dot monu23 at gmail dot com | Date: | Mon, 03 Feb 2014 12:07:53 +0000 |
| Subject: | note 114290 added to function.trader-ema | ||
| Groups: | php.notes php.notes | ||
| Request: | Send a blank email to php-notes+get-198397@lists.php.net to get a copy of this message | ||
the trader_ema() function does'nt work correctly , it calculate just average of last period
entries. Follow the following code for trader_ema:
function EMACalculator($limit,$array)
{
$EMA_previous_day = $array[0];
//print_r($array);
$multiplier1 = (2/$limit+1);
$EMA[]=array();
$EMA = $array[0];
$Close= $array[1];
while($limit)
{
//echo"EMA is $EMA\n";
$EMA = ($Close - $EMA_previous_day) * $multiplier1 + $EMA_previous_day;
$EMA_previous_day= $EMA;
$limit--;
}
return $EMA;
}
where $limit accept the period of ema and $array : accept array of data for ema calculation.
----
Server IP: 72.52.91.14
Probable Submitter: 72.52.91.14
----
Manual Page -- http://php.net/manual/en/function.trader-ema.php
Edit -- https://master.php.net/note/edit/114290
Del: integrated -- https://master.php.net/note/delete/114290/integrated
Del: useless -- https://master.php.net/note/delete/114290/useless
Del: bad code -- https://master.php.net/note/delete/114290/bad+code
Del: spam -- https://master.php.net/note/delete/114290/spam
Del: non-english -- https://master.php.net/note/delete/114290/non-english
Del: in docs -- https://master.php.net/note/delete/114290/in+docs
Del: other reasons-- https://master.php.net/note/delete/114290
Reject -- https://master.php.net/note/reject/114290
Search -- https://master.php.net/manage/user-notes.php