<<CUT & PASTE FROM Yahoo! Group>>
To: ta-lib@yahoogroups.com
From: "mdmoon" <PROTECTED>
Date: Sun, 31 Mar 2002 15:02:15 -0000
Subject: [ta-lib] TA_HistoryAlloc Error
Reply-to: ta-lib@yahoogroups.com
Mario,
This is my first attempt to use TA-Lib (latest Beta
release 4). I'm also using VC++ 6.0 on a Win2K
machine. I thought that using the simulated date
would be the simplest approach, but am receiving an
error from the TA_HistoryAlloc function call. What is
the silly thing that I'm doing wrong here?
Please see below for a simple method associated with
the clicking of a button on a form. Most of the code
is copied verbatim from the example in your online
documentation.
Max
==================================================
void CTa_libDlg::InitTALib()
{
TA_Lib *libHandle;
TA_UDBase *unifiedDatabase;
TA_History *data;
TA_RetCode retCode;
TA_InitializeParam param;
TA_AddDataSourceParam addParam;
CString strTmp;
memset( &param, 0, sizeof( TA_InitializeParam ) );
param.logOutput = stdout;
retCode = TA_Initialize( &libHandle, &param );
if( retCode != TA_SUCCESS )
{
strTmp.Format( "Cannot initialize TA-LIB (%d)!",
retCode );
MessageBox(strTmp);
}
else
{
// MessageBox( "TA-LIB correctly initialized." );
/* Create an unified database. */
if( TA_UDBaseAlloc( libHandle, &unifiedDatabase ) !
= TA_SUCCESS )
{
TA_Shutdown( libHandle );
MessageBox("Cannot create unifiedDatabase!");
}
else
{
MessageBox( "unifiedDatabase created
successfully." );
/* USE SIMULATOR DATA */
memset( &addParam, 0, sizeof(
TA_AddDataSourceParam ) );
addParam.id = TA_SIMULATOR;
addParam.flags = TA_NO_FLAGS;
retCode = TA_AddDataSource( unifiedDatabase,
&addParam );
/* Now, display all daily close price available
* for the DAILY_REF_0 symbol.
*/
if( retCode == TA_SUCCESS )
{
MessageBox( "TA_SIMULATOR DataSource added
successfully." );
retCode = TA_HistoryAlloc( unifiedDatabase,
"TA_SIM_REF", "DAILY_
REF_0",
TA_DAILY, 0, 0,
TA_CLOSE|TA_VOLUME,
&data );
if( retCode == TA_SUCCESS )
{
//for( i=0; i < data->nbBars; i++ )
MessageBox( "HistoryAlloc for TA_SIMULATOR
successful." );
for(int i=0; i < 1; i++ )
{
strTmp.Format( "%f %d\n", data->close[i],
data->volume
[i] );
MessageBox(strTmp);
}
TA_HistoryFree( data );
}
else
{
// **************** KEEP GETTING THIS ERROR (65535
Return Code)
************
strTmp.Format( "Cannot TA_HistoryAlloc for
TA_SIM_REF (%
d)!", retCode );
MessageBox(strTmp);
}
}
/* Clean-up and exit. */
TA_UDBaseFree( unifiedDatabase );
TA_Shutdown( libHandle );
}
}
}
Logged In: YES
user_id=1123
<<CUT & PASTE FROM Yahoo! Group>>
Max, thanks for reporting a bug.
The fix will be included in the next release (V0.0.5)
In the mean time, you can work-around this by using
TA_ALL instead of specifying a subset of field
(TA_CLOSE|TA_VOLUME).
If someone wishes to correct immediatly the code, use
the attach file:
ta_data\ta_history\ta_history_builder.c
Keep providing good feedback,
\Mario
Fix for the bug
Logged In: YES
user_id=1123
This is now fixed in V0.0.5
Contributed patch, already applied. TA-Lib has moved to GitHub and this SourceForge tracker is retired.
This ticket carried a contributed patch (
ta_history_builder.c) and was resolved asclosed-fixedon SourceForge in 2002. It is accounted for in the final SourceForge review: https://github.com/TA-Lib/ta-lib/issues/30No further support is provided on SourceForge. Please send patches as pull requests on GitHub instead:
Thank you for the contribution.