English | 简体中文 | 繁體中文
查询

trader_typprice()函数—用法及示例

「 计算传入时间段内的典型价格 」


函数名:trader_typprice()

适用版本:PHP 5 >= 5.6.0, PHP 7

函数描述:trader_typprice() 函数计算传入时间段内的典型价格。典型价格是指某个时间段内最高价、最低价和收盘价的平均值。

用法:

trader_typprice ( array $high , array $low , array $close ) : array

参数:

  • $high:一个包含最高价的数组。
  • $low:一个包含最低价的数组。
  • $close:一个包含收盘价的数组。

返回值:

  • 返回一个包含计算出的典型价格的数组。

示例:

$high = [10.5, 11.2, 12.1, 10.8, 11.5];
$low = [9.8, 10.7, 11.0, 10.5, 10.2];
$close = [10.2, 10.9, 11.8, 10.6, 11.3];

$typPrice = trader_typprice($high, $low, $close);

print_r($typPrice);

输出:

Array
(
    [0] => 10.166666666667
    [1] => 10.933333333333
    [2] => 11.633333333333
    [3] => 10.633333333333
    [4] => 11
)

在上面的示例中,我们传入了一个包含最高价、最低价和收盘价的数组,并使用 trader_typprice() 函数计算出了每个时间段内的典型价格。最后,我们打印出计算出的典型价格的数组。

补充纠错
上一个函数: trader_ultosc()函数
下一个函数: trader_tsf()函数
热门PHP函数
分享链接