This code
$real = array (1, 2, 3, 4, 9 ) ;
$timePeriod = 5;
$data = trader_sma($real,$timePeriod);
$ta_sma = $data[4];
echo $ta_sma;
Gives nice result of "3.8"
But this one
$real = array (0.00035606, 0.00035571, 0.00035607, 0.00035606, 5.00035607);
$timePeriod = 5;
$data = trader_sma($real,$timePeriod);
$ta_sma = $data[4];
echo $ta_sma;
is giving "1" (no decimal numbers)
I tried all possible number_format combinations and could not get normal result in 2nd code
How to format this to get real number which is 1,000355994?
Looking here - php trader configuration we can figure out two options:
Set an trader.real_precision
option in php.ini to 9
, which means the precision of rounding (amount of numbers after the dot)
Set it directly in the script:
ini_set('trader.real_precision', '9');
And we have in output:
array(1) {
[4]=>
float(1.000355994)
}