牛牛在线工具

trader_plus_di()

收录 8868 个 PHP 函数,含用途说明与用法示例。

trader_plus_di()

计算加法指标(Plus Directional Indicator,简称PDI),PDI用于衡量上升趋势的强度

函数名: trader_plus_di() 适用版本: PHP 5 >= 5.2.0, PHP 7 函数说明: trader_plus_di() 函数用于计算加法指标(Plus Directional Indicator,简称PDI),PDI用于衡量上升趋势的强度。PDI是平均方向指数(Average Directional Index,简称ADX)的一个组成部分。 语法: trader_plus_di ( array $high , array $low , array $close , int $timePeriod ) : array 参数: $high: 高价数组,包含了一系列高价数据。 $low: 低价数组,包含了一系列低价数据。 $close: 收盘价数组,包含了一系列收盘价数据。 $timePeriod: 计算PDI所需的时间段。 返回值:返回一个包含计算出的PDI值的数组,或者在失败时返回false。 示例: $high = [10.25, 10.50, 10.75, 11.00, 11.25, 11.50, 11.75]; $low = [9.75, 10.00, 10.25, 10.50, 10.75, 11.00, 11.25]; $close = [10.00, 10.25, 10.50, 10.75, 11.00, 11.25, 11.50]; $timePeriod = 5; $result = trader_plus_di($high, $low, $close, $timePeriod); if ($result !== false) { print_r($result); } else { echo "计算PDI失败"; } 输出: Array ( [4] => 31.25 [5] => 29.55 [6] => 27.88 ) 上述示例中,我们计算了一个包含7个交易日的PDI值,时间段为5。结果数组中的键值表示对应交易日的索引,对应的值为计算出的PDI值。在这个示例中,第5个交易日的PDI为29.55。