【发布时间】:2016-11-29 23:51:28
【问题描述】:
我正在尝试使用 C++ 中的 ta-lib 库对 this data 进行一些技术分析。 ta-lib 的问题在于,关于它们在 C++ 中的用法的教程很少(很可能除了文档之外没有)。我将电子表格中的open 值(第三/C 列)转换为大小为 124 的向量 double vec。我想使用此向量计算 10 天周期的 EMA 和 RSI。这是
//headers used
#include <vector>
#include <ta-lib/ta_libc.h>
std::vector <double> vec;
//Technical analysis part of the code
int n=vec.size(); //size of the vector
std::cout <<"size "<< n << ' ';
TA_RetCode retCode;
retCode = TA_Initialize( );
if( retCode != TA_SUCCESS )
std::cout<<"Cannot initialize TA-Lib !\n"<< retCode <"\n";
else
{
std::cout<<"TA-Lib correctly initialized.\n" ;
/* ... other TA-Lib functions can be used here. */
double ma=TA_MA(0,n,vec,10,TA_MAType_EMA);
double rsi=TA_RSI(0,n,vec,10);
std::cout <<"EMA "<< ma <<"\n";
std::cout <<"RSI "<< rsi <<"\n";
TA_Shutdown();
}
错误是
错误:无法将“std::vector”转换为“const double*” 参数‘3’到‘TA_RetCode TA_MA(int, int, const double*, int, TA_MAType, int*, int*, double*)
【问题讨论】:
-
不要垃圾标签! C++ 不是 C 不是 C++。
-
亲爱的 olaf,但 C++ 和 C 是相关的,C 中也使用了相同的 ta-lib 库。所以它们不相关吗?
-
因为 C# 和 Cobol 也是相关的,因为它们都以相同的字母开头。请告诉我一个可以生成该错误消息的 C 编译器! (并正确处理 cmets。以tour)
-
@Olaf 我同意,但我们可以一起运行 c 和 cpp 代码
#include <iostream> #include <stdio.h> int main(){ std::cout<<"hello "; printf("world"); return 0; }
标签: c++ ta-lib technical-indicator