【问题标题】:Example usage of TA-LIB trader_sma function?TA-LIB trader_sma 函数的示例用法?
【发布时间】:2015-04-30 21:20:21
【问题描述】:

我刚刚将 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 ] )


?>

任何帮助表示赞赏。谢谢。

【问题讨论】:

    标签: php ta-lib


    【解决方案1】:

    $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 = 34 34 / 3 = 11.333

    array(float 11.333,
          float 17, etc...
    

    【讨论】:

    • 12+15+17 =44。 44/3 = 14.66667。只是为了正确。
    猜你喜欢
    • 2020-06-14
    • 1970-01-01
    • 2021-07-29
    • 1970-01-01
    • 1970-01-01
    • 2017-03-09
    • 1970-01-01
    • 2023-01-14
    • 2022-01-23
    相关资源
    最近更新 更多