So I have this function (what's inside isn't really important because it works), and when I print any of the arrays at the bottom (eg. $stdDevArraycomparison), it works. However if I call the function and then try to print the array, it doesn't do anything. Why can't I print the array after calling the function?
function TickerResearch ($results, $period, $volinterval) {
for ($x = 2; $x < count($resultscomparison) - 1; $x++) {
$residualsArraycomparison[$x - 2] = round(($resultscomparison[$x] / $resultscomparison[$x + 1]) - 1, 5); // this is the residuals array that I will use for RSI along with the histograms.
}
for ($x = 0; $x < count($residualsArraycomparison) - $period; $x++) {
for ($y = 0; $y < $period; $y++) {
if ($residualsArraycomparison[$x + $y] > 0) {
$upcomparison[$x]++; // no need to define it as 0 beforehand.
}
}
}
for($x = 2; $x < count($resultscomparison) - $period; $x++) {
for ($y = 0; $y < $period; $y++) {
$residualscomparison[$y] = ($resultscomparison[$x + $y] / $resultscomparison[$x + $y + 1]) - 1;
}
$residualsAverage = array_sum($residualscomparison) / count($residualscomparison);
for ($y = 0; $y < $period; $y++) {
$residualsSub[$y] = pow($residualscomparison[$y] - $residualsAverage, 2); // for std dev
$third_moment[$y] = pow($residualscomparison[$y] - $residualsAverage, 3); // for skewness
$fourth_moment[$y] = pow($residualscomparison[$y] - $residualsAverage, 4); // for kurtosis
}
$third_momentSum = array_sum($third_moment);
$fourth_momentSum = array_sum($fourth_moment);
$variance = array_sum($residualsSub) / count($residualsSub);
$stdDevArraycomparison[$x] = pow($variance, 0.5);
$skewnessArraycomparison[$x] = $third_momentSum / (($period - 1) * pow($stdDevArraycomparison[$x], 3)); // | These are both similar. Kurtosis is calculated on
$kurtosisArraycomparison[$x] = ($fourth_momentSum / (($period - 1) * pow($stdDevArraycomparison[$x], 4)) - 3); // | fours while skewness is calculated on threes.
}
for ($x = 0; $x < count($upcomparison); $x++) {
$upArraycomparison[$x] = 100 - 100/(1 + ($upcomparison[$x] / ($period - $upcomparison[$x])));
}
// print_r($stdDevArraycomparison) would work here.
}
TickerResearch($results, $period, $volinterval);
// print_r($stdDevArraycomparison) WON'T work here.