function getSMACombined($company, $from = "1900-01-01 00:00:00", $to = null, $dataorg = "json", $periodShort = 20, $periodMedium = 50, $periodLong = 120, $enSignals = false, $host, $db, $user, $pass) { $smaShort = getSMA($company, $from, $to, $dataorg, $periodShort, $enSignals, false, $host, $db, $user, $pass); $smaMedium = getSMA($company, $from, $to, $dataorg, $periodMedium, $enSignals, false, $host, $db, $user, $pass); $smaLong = getSMA($company, $from, $to, $dataorg, $periodLong, $enSignals, false, $host, $db, $user, $pass); $real = getSMA_sub_real($company, $from, $to, $dataorg, $periodShort, $enSignals, $host, $db, $user, $pass); if ($smaShort == 0 || $smaMedium == 0 || $smaLong == 0 || $real == 0) { return 0; } $allData = []; if (strcasecmp($enSignals, "latest") == 0) { //return only the latest signal // [timestamp,trade signal] $lastSignal = codesword_smaBuySellSignalCombinedLatests($real, $smaShort, $smaMedium, $smaLong, $dataorg); return $lastSignal; } elseif ($enSignals) { $allData = codesword_smaBuySellSignalCombined($real, $smaShort, $smaMedium, $smaLong, $dataorg); echo json_encode($allData); } else { $allData[0] = codesword_smaConsolidate($real, $smaShort, $smaMedium, $smaLong); $allData[1] = 0; echo json_encode($allData); } }
function codesword_smaBuySellSignalCombinedLatests($real, $smaShort, $smaMedium, $smaLong, $dataorg = "json") { $smac = codesword_smaBuySellSignalCombined($real, $smaShort, $smaMedium, $smaLong, $dataorg); $signals = $smac[1]; return $signals[count($signals) - 1]; // return $smac[1]; }