我刚刚将TA-Lib/trader安装到我的php安装中,这很好。我的PHP不太好,即使有交易员文档,我也只需要一些指导。我想从数据库中加载一组值,并将它们发送到"trader_sma"中,以获得小的移动平均值。我的伪代码看起来像:
<?php
$finance = $dbrequest("SELECT close_price FROM market_table WHERE stock='$symbol');
//So now $finance is an array with all of the stocks closing prices
//how do I place it into this function? I also need to 'count' the rows in
//the array to send them into $timePeriod?
//array trader_sma ( array $real [, integer $timePeriod ] )
?>
感谢您的帮助。谢谢
$real
将是您输入的值,$timePeriod
是指定移动平均线长度的整数。
因此,您将使用这样的功能:
$real = array(12,15,17,19,21,25,28,12,15,16);
$timePeriod = 3;
$data = trader_sma($real,$timePeriod);
var_dump($data);
输出将是一个三增量移动平均值的数组。。。
12+15+17=3434/3=11.333
array(float 11.333,
float 17, etc...