dongtui2029 2015-02-28 02:13 采纳率: 0%
浏览 178

TA-LIB trader_sma函数的使用示例?

I just installed TA-Lib / trader into my php installation and it's good to go. My PHP isn't great and even with the trader documentation I just need a bit of guidance. I want to load an array of values from my database and send them into "trader_sma" to get the small moving average. My pseudo code will look something like:

<?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 ] )


?>

Any help appreciated. Thanks.

  • 写回答

1条回答 默认 最新

  • douchensou6969 2015-08-31 15:53
    关注

    $real will be the values you are inputting and $timePeriod is an integer that specifies the length of the moving average.

    Therefore you would use the function like this:

    $real = array(12,15,17,19,21,25,28,12,15,16);
    $timePeriod = 3;
    $data = trader_sma($real,$timePeriod);
    var_dump($data);
    

    The output will be array of a three increment moving average...

    12 + 15 + 17 = 34 34 / 3 = 11.333

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

报告相同问题?

悬赏问题

  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程