trufanov-nok / ta-lib-rt

TA-Lib RT is a fork of TA-Lib that provides additional API for incremental calculation of indicators without reprocessing whole data.
http://ta-lib.org
83 stars 30 forks source link

Some CDL functions seem to not work #9

Closed sunpavlik closed 4 years ago

sunpavlik commented 4 years ago

Hello,

I was testing CLD functions using the same inputs, only changing function name and some CDL functions work and some crash in TA_CallFuncState(holder). The list below is not exhaustive just a sample. Please could you tell what I am missing?

Work: CDLKICKING CDLHARAMI

Do not work: CDLSPINNINGTOP CDLSHORTLINE CDLLONGLINE

trufanov-nok commented 4 years ago

could you provide a small example for, let's say CDLLONGLINE, that demonstrates the crash?

sunpavlik commented 4 years ago
const TA_FuncHandle *handle;
const TA_FuncInfo *theInfo;
TA_RetCode retCode = TA_GetFuncHandle( "CDLLONGLINE", &handle );
if( retCode != TA_SUCCESS )
    return;

retCode = TA_GetFuncInfo( handle, &theInfo );
if ( retCode != TA_SUCCESS )
    return;

TA_ParamHolder* holder;
retCode = TA_ParamHolderAlloc(theInfo->handle, &holder);
if ( retCode != TA_SUCCESS )
    return;

int result;
retCode = TA_SetOutputParamIntegerPtr(holder, 0, &result);
if ( retCode != TA_SUCCESS )
    return;

TA_Real price[6];
retCode = TA_SetInputParamPricePtr(holder, 0, &price[0], &price[1], &price[2], &price[3], &price[4], &price[5]);
if ( retCode != TA_SUCCESS )
    return;

retCode = TA_InitNewState( holder );
if ( retCode != TA_SUCCESS )
    return;

price[0] = 38.16;
price[1] = 38.165;
price[2] = 38.16;
price[3] = 38.165;

retCode = TA_CallFuncState(holder);
trufanov-nok commented 4 years ago

You must call once TA_Initialize(); before any access to TA-Lib's C++ API. That's by original design. Best place to call it is application's main(). This function initializes some global variables and seems to set up candle default settings.

sunpavlik commented 4 years ago

I see, cool, thank you