#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "ta_common.h"
#include "ta_magic_nb.h"
#include "ta_global.h"
#include "ta_func.h"
#ifdef TA_LIB_PRO
#endif
TA_LibcPriv ta_theGlobals = {0,{{0,0,0}},0,0,0,0,(TA_Compatibility)0,{0},{{(TA_CandleSettingType)0,(TA_RangeType)0,0,0}}};
TA_LibcPriv *TA_Globals = &ta_theGlobals;
TA_RetCode TA_Initialize( void )
{
memset( TA_Globals, 0, sizeof( TA_LibcPriv ) );
TA_Globals->magicNb = TA_LIBC_PRIV_MAGIC_NB;
#ifdef TA_LIB_PRO
#endif
TA_RestoreCandleDefaultSettings( TA_AllCandleSettings );
return TA_SUCCESS;
}
TA_RetCode TA_Shutdown( void )
{
if( TA_Globals->magicNb != TA_LIBC_PRIV_MAGIC_NB )
return TA_LIB_NOT_INITIALIZE;
memset( TA_Globals, 0, sizeof( TA_LibcPriv ) );
return TA_SUCCESS;
}
TA_RetCode TA_SetCandleSettings( TA_CandleSettingType settingType,
TA_RangeType rangeType,
int avgPeriod,
double factor )
{
if( settingType >= TA_AllCandleSettings )
return TA_BAD_PARAM;
TA_Globals->candleSettings[settingType].settingType = settingType;
TA_Globals->candleSettings[settingType].rangeType = rangeType;
TA_Globals->candleSettings[settingType].avgPeriod = avgPeriod;
TA_Globals->candleSettings[settingType].factor = factor;
return TA_SUCCESS;
}
TA_RetCode TA_RestoreCandleDefaultSettings( TA_CandleSettingType settingType )
{
const TA_CandleSetting TA_CandleDefaultSettings[] = {
{ TA_BodyLong, TA_RangeType_RealBody, 10, 1.0 },
{ TA_BodyVeryLong, TA_RangeType_RealBody, 10, 3.0 },
{ TA_BodyShort, TA_RangeType_RealBody, 10, 1.0 },
{ TA_BodyDoji, TA_RangeType_HighLow, 10, 0.1 },
{ TA_ShadowLong, TA_RangeType_RealBody, 0, 1.0 },
{ TA_ShadowVeryLong, TA_RangeType_RealBody, 0, 2.0 },
{ TA_ShadowShort, TA_RangeType_Shadows, 10, 1.0 },
{ TA_ShadowVeryShort, TA_RangeType_HighLow, 10, 0.1 },
{ TA_Near, TA_RangeType_HighLow, 5, 0.2 },
{ TA_Far, TA_RangeType_HighLow, 5, 0.6 },
{ TA_Equal, TA_RangeType_HighLow, 5, 0.05 }
};
int i;
if( settingType > TA_AllCandleSettings )
return TA_BAD_PARAM;
if( settingType == TA_AllCandleSettings )
for( i = 0; i < TA_AllCandleSettings; ++i )
TA_Globals->candleSettings[i] = TA_CandleDefaultSettings[i];
else
TA_Globals->candleSettings[settingType] = TA_CandleDefaultSettings[settingType];
return TA_SUCCESS;
}