I am trying to do some technical analysis of this data using ta-lib library in C++. The problem with ta-lib
is that there is very few(most probably none except documentation) tutorials regarding their usage in C++. I converted the open
values (third/C-th column) in the spreadsheet to a vector double vec
of size 124. I want to use this vector for the calculation of EMA and RSI of 10 day period. This is
//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();
}
The error is
error: cannot convert ‘std::vector’ to ‘const double*’ for argument ‘3’ to ‘TA_RetCode TA_MA(int, int, const double*, int, TA_MAType, int*, int*, double*)