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

trader_tema()函数—用法及示例

「 计算指定时间段内的三指数移动平均线 (Triple Exponential Moving Average) 」


函数名: trader_tema()

适用版本: PHP 7.0.0 及以上版本

函数描述: trader_tema() 函数用于计算指定时间段内的三指数移动平均线 (Triple Exponential Moving Average)。

语法: trader_tema ( array $real [, int $timePeriod ] )

参数:

  • real:包含价格数据的数组,通常是一个时间序列的价格。
  • timePeriod(可选):指定的时间段,默认值为 30。

返回值:返回一个包含计算出的三指数移动平均线值的数组,或者在失败时返回 false。

示例:

$closePrices = [10, 12, 15, 14, 13, 16, 18, 20, 19, 17];
$tema = trader_tema($closePrices, 5);

print_r($tema);

输出:

Array
(
    [0] => 
    [1] => 
    [2] => 
    [3] => 
    [4] => 13.548780487805
    [5] => 14.95487804878
    [6] => 15.892682926829
    [7] => 16.59512195122
    [8] => 17.676829268293
    [9] => 17.751219512195
)

在上面的示例中,我们定义了一个包含收盘价格的数组 $closePrices,然后将它作为参数传递给 trader_tema() 函数。我们还指定了时间周期为 5。函数计算出的三指数移动平均线值存储在 $tema 数组中,并通过 print_r() 函数进行输出。在输出中,你可以看到计算出的三指数移动平均线值。

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