函数名:trader_minus_di()
适用版本:PHP 7.0.0及以上版本
函数说明:trader_minus_di()函数用于计算股票或其他金融工具的负向指标(Negative Directional Indicator,简称DI-)。DI-是一种技术指标,用于衡量股价下跌的力量和方向。它通常与其他技术指标一起使用,如DI+(Positive Directional Indicator,简称DI+)和ADX(Average Directional Index,简称ADX)。
语法:trader_minus_di(array $high, array $low, array $close, int $timePeriod = 14) : array
参数:
- $high:包含高价格的数组,一般是按照时间顺序排列的。
- $low:包含低价格的数组,与$high数组相对应。
- $close:包含收盘价格的数组,与$high和$low数组相对应。
- $timePeriod(可选):计算DI-的时间周期,默认值为14。
返回值:返回一个包含DI-值的数组,数组的长度与输入的数组长度相同。
示例:
$high = [45.92, 45.66, 45.90, 46.24, 45.78, 45.35, 45.41, 45.44, 45.20, 45.42, 45.84, 46.08, 46.25, 46.23];
$low = [45.01, 45.24, 45.70, 45.80, 45.53, 45.04, 44.94, 45.14, 44.93, 44.61, 45.22, 45.89, 45.89, 45.80];
$close = [45.80, 45.48, 45.75, 46.21, 45.62, 45.15, 45.23, 45.25, 45.02, 45.32, 45.74, 46.08, 46.18, 46.15];
$result = trader_minus_di($high, $low, $close);
print_r($result);
输出:
Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 0
[4] => 0
[5] => 0
[6] => 0
[7] => 0
[8] => 0
[9] => 0
[10] => 0
[11] => 0
[12] => 0
[13] => 0
)
注意:以上示例中的输出结果都为0,这是因为示例数据的长度不足以计算出有效的DI-值。在实际使用时,应该提供足够的历史价格数据以计算准确的DI-值。