i can use talib MACD function correctly in python, but it failed in c++.
talib is easy to use in python, i can use it as:
MACD(close, 12, 26,9) # close is a pandas series
but when i use it in c++, it confuses me about the params.
I have a function which update one close price for one time, so i save the close price sequence in a vector, like this:
std::vector<double> close_price;
void f(double new_close) {
close_price.push_back(new_close);
std::vector<TA_Real> a(655360, 0.0);
std::vector<TA_Real> b(655360, 0.0);
std::vector<TA_Real> c(655360, 0.0);
int s, n;
TA_RetCode retCode = TA_MACD(0, close_price.size(), close_price.data(), 3, 12, 1, &s, &n, a.data(), b.data(), c.data());
assert(retCode == TA_SUCCESS);
}
but it always failed in assert, ERROR message is:
Error 5119(TA_INTERNAL_ERROR): Unexpected Internal Error - Contact TA-Lib.org
did i miss anything? i think i passin the parameters as the example talib provide.
endIdx
is the last index, not the size. Hence, you need to call it as:
TA_MACD(..., close_price.size() - 1, ...);