PHP 8.4.0 RC4 available for testing

trader_apo

(PECL trader >= 0.2.0)

trader_apoAbsolute Price Oscillator

説明

trader_apo(
    array $real,
    int $fastPeriod = ?,
    int $slowPeriod = ?,
    int $mAType = ?
): array

パラメータ

real

実数値の配列。

fastPeriod

Number of period for the fast MA. Valid range from 2 to 100000.

slowPeriod

Number of period for the slow MA. Valid range from 2 to 100000.

mAType

Type of Moving Average. TRADER_MA_TYPE_* series of constants should be used.

戻り値

Returns an array with calculated data or false on failure.

add a note

User Contributed Notes 1 note

up
4
geekgirl dot joy at gmail dot com
3 years ago
<?php
/*
APO crossing above zero is "bullish", crossing below zero is "bearish".
Positive values are "upward movement", Negative values are "downward movement",
*/

$mATypes = array(TRADER_MA_TYPE_SMA, // Simple Moving Average
TRADER_MA_TYPE_EMA, // Exponential Moving Average
TRADER_MA_TYPE_WMA, // Weighted Moving Average
TRADER_MA_TYPE_DEMA, // Double Exponential Moving Average
TRADER_MA_TYPE_TEMA, // Triple Exponential Moving Average
TRADER_MA_TYPE_TRIMA,// Triangular Moving Average
TRADER_MA_TYPE_KAMA, // Kaufman's Adaptive Moving Average
TRADER_MA_TYPE_MAMA, // MESA Adaptive Moving Average
TRADER_MA_TYPE_T3); // T3 Moving Average

$fast_period = 12;
$slow_period = 30;

$closes = array(131.96, 137.09, 142.06, 143.16, 142.92, 139.07, 136.87, 132.03, 127.83, 127.14, 128.91, 130.89, 128.8, 128.98, 132.05, 130.92, 126.6, 131.01, 129.41, 132.69, 133.72, 134.87, 136.69, 131.97, 130.96, 131.88, 128.23, 126.655, 128.7, 127.81, 127.88, 121.78, 122.41, 123.24, 121.78, 124.38, 123.75, 122.25, 122.94, 123.08, 122.72, 119.05, 116.59, 116.03, 115.17, 113.85, 117.34, 118.64, 118.03, 119.39, 120.3, 119.26, 119.21, 119.49, 115.97, 116.32, 118.69, 119.03, 114.95, 110.44, 108.77, 108.86, 115.32, 111.2, 116.6, 115.05, 115.04, 115.75, 116.87, 117.51, 115.98, 119.02, 120.71, 121.19, 121.1, 124.4, 116.97, 114.97, 115.08, 113.16, 116.5, 113.02, 116.79, 115.81, 114.09, 114.96, 112.28, 108.22, 107.12, 111.81, 110.08, 106.84, 110.34, 112.13, 115.54, 115.355, 112, 113.49, 117.32, 112.82);

$Absolute_Price_Oscillators = array();

foreach(
$mATypes as $mA){

$key = 'sma';
if(
$mA == TRADER_MA_TYPE_EMA){$key = 'ema';}
elseif(
$mA == TRADER_MA_TYPE_WMA){$key = 'wma';}
elseif(
$mA == TRADER_MA_TYPE_DEMA){$key = 'dema';}
elseif(
$mA == TRADER_MA_TYPE_TEMA){$key = 'tema';}
elseif(
$mA == TRADER_MA_TYPE_TRIMA){$key = 'trima';}
elseif(
$mA == TRADER_MA_TYPE_KAMA){$key = 'kama';}
elseif(
$mA == TRADER_MA_TYPE_MAMA){$key = 'mama';}
elseif(
$mA == TRADER_MA_TYPE_T3){$key = 't3';}

$Absolute_Price_Oscillators[$key] = trader_apo ($closes, $fast_period, $slow_period, $mA);
}

var_dump($Absolute_Price_Oscillators['sma']);
/*
array(71) {
[29]=>
float(-1.264)
[30]=>
float(-1.255)
[31]=>
float(-1.654)
[32]=>
float(-1.942)
[33]=>
float(-2.247)
[34]=>
float(-2.785)
[35]=>
float(-2.927)
[36]=>
float(-3.091)
[37]=>
float(-3.567)
[38]=>
float(-3.845)
[39]=>
float(-4.008)
[40]=>
float(-4.3)
[41]=>
float(-4.635)
[42]=>
float(-5.169)
[43]=>
float(-5.217)
[44]=>
float(-5.257)
[45]=>
float(-5.471)
[46]=>
float(-5.532)
[47]=>
float(-5.598)
[48]=>
float(-5.695)
[49]=>
float(-5.49)
[50]=>
float(-5.263)
[51]=>
float(-5.061)
[52]=>
float(-4.771)
[53]=>
float(-4.318)
[54]=>
float(-3.87)
[55]=>
float(-3.327)
[56]=>
float(-2.716)
[57]=>
float(-2.03)
[58]=>
float(-1.771)
[59]=>
float(-1.875)
[60]=>
float(-2.01)
[61]=>
float(-2.457)
[62]=>
float(-2.636)
[63]=>
float(-2.906)
[64]=>
float(-2.951)
[65]=>
float(-3.01)
[66]=>
float(-2.797)
[67]=>
float(-2.628)
[68]=>
float(-2.577)
[69]=>
float(-2.518)
[70]=>
float(-2.208)
[71]=>
float(-1.492)
[72]=>
float(-0.634)
[73]=>
float(0.222)
[74]=>
float(0.506)
[75]=>
float(1.254)
[76]=>
float(1.297)
[77]=>
float(1.413)
[78]=>
float(1.515)
[79]=>
float(1.506)
[80]=>
float(1.602)
[81]=>
float(1.436)
[82]=>
float(1.584)
[83]=>
float(1.439)
[84]=>
float(0.95)
[85]=>
float(0.477)
[86]=>
float(-0.045)
[87]=>
float(-1.033)
[88]=>
float(-1.593)
[89]=>
float(-1.902)
[90]=>
float(-2.362)
[91]=>
float(-2.821)
[92]=>
float(-3.169)
[93]=>
float(-3.274)
[94]=>
float(-3.343)
[95]=>
float(-3.391)
[96]=>
float(-3.464)
[97]=>
float(-3.511)
[98]=>
float(-3.106)
[99]=>
float(-2.566)
}
*/
To Top