- TA_Real closePrice[400];
- TA_Real out[400];
- TA_Integer outBeg;
- TA_Integer outNbElement;
- 这是定义参数的地方
- int main(int argc, char* argv[])
- {
- /* The output is displayed here */
- for(int j=0;j<401;)
- {
- closePrice[j++]=1; //closePrice指的是收盘价MACD,MA等技术图形都是根据收盘价格形成的图形
- }
- TA_RetCode retCode = TA_MA(0,399,&closePrice[0],30,TA_MAType_SMA,&outBeg,&outNbElement,&out[0]);
- //这里传参数
- for(int i=0; i < outNbElement; i++ )
- printf( "Day %d = %f/n", outBeg+i, out[i] );
- return 0;
- }
在C库中有重要的ta_defs.h,ta_common.h,ta_func.h三个重要的头文件
ta_libc.h是所有头文件的定义开始
ta_defs.h用来定义Ta lib 的数据类型包括一些常用的类型。ta_func.h是技术分析公式的头文件,如果你要找到MACD公式的
定义可以这样查找 TA_MACD 如果找CCI,可以TA_CCI
在VC中的LINK面板中要加入这N多个库文件的Link
比如:ta_abstract_ ta_common_,ta_func_cdd.,ta_libc_cdd前缀开始的LIB库
每个有_cdd,_cdr,_cmd,_cmr,_csd,csr_ 所以有N多个。
主要需要如下库:
ta_libc_csr.lib ta_libc_csd.lib ta_libc_cmr.lib ta_libc_cmd.lib ta_libc_cdr.lib ta_libc_cdd.lib
(更正)
为了满足其他开发语言的需求,每个公式上面定义了很多编译控制。要使用要注意一下。
- /* Generated */ #if defined( _MANAGED ) && defined( USE_SUBARRAY )
- /* Generated */ enum class Core::RetCode Core::Macd( int startIdx,
- /* Generated */ int endIdx,
- /* Generated */ SubArray^ inReal,
- /* Generated */ int optInFastPeriod, /* From 2 to 100000 */
- /* Generated */ int optInSlowPeriod, /* From 2 to 100000 */
- /* Generated */ int optInSignalPeriod, /* From 1 to 100000 */
- /* Generated */ [Out]int% outBegIdx,
- /* Generated */ [Out]int% outNBElement,
- /* Generated */ cli::array<double>^ outMACD,
- /* Generated */ cli::array<double>^ outMACDSignal,
- /* Generated */ cli::array<double>^ outMACDHist )
- /* Generated */ #elif defined( _MANAGED )
- /* Generated */ enum class Core::RetCode Core::Macd( int startIdx,
- /* Generated */ int endIdx,
- /* Generated */ cli::array<double>^ inReal,
- /* Generated */ int optInFastPeriod, /* From 2 to 100000 */
- /* Generated */ int optInSlowPeriod, /* From 2 to 100000 */
- /* Generated */ int optInSignalPeriod, /* From 1 to 100000 */
- /* Generated */ [Out]int% outBegIdx,
- /* Generated */ [Out]int% outNBElement,
- /* Generated */ cli::array<double>^ outMACD,
- /* Generated */ cli::array<double>^ outMACDSignal,
- /* Generated */ cli::array<double>^ outMACDHist )
- /* Generated */ #elif defined( _JAVA )
- /* Generated */ public RetCode macd( int startIdx,
- /* Generated */ int endIdx,
- /* Generated */ double inReal[],
- /* Generated */ int optInFastPeriod, /* From 2 to 100000 */
- /* Generated */ int optInSlowPeriod, /* From 2 to 100000 */
- /* Generated */ int optInSignalPeriod, /* From 1 to 100000 */
- /* Generated */ MInteger outBegIdx,
- /* Generated */ MInteger outNBElement,
- /* Generated */ double outMACD[],
- /* Generated */ double outMACDSignal[],
- /* Generated */ double outMACDHist[] )
- /* Generated */ #else
- /* Generated */ TA_RetCode TA_MACD( int startIdx,
- /* Generated */ int endIdx,
- /* Generated */ const double inReal[],
- /* Generated */ int optInFastPeriod, /* From 2 to 100000 */
- /* Generated */ int optInSlowPeriod, /* From 2 to 100000 */
- /* Generated */ int optInSignalPeriod, /* From 1 to 100000 */
- /* Generated */ int *outBegIdx,
- /* Generated */ int *outNBElement,
- /* Generated */ double outMACD[],
- /* Generated */ double outMACDSignal[],
- /* Generated */ double outMACDHist[] )
关注升级版本。至于如果只是单纯应用。将LIB导入就行。如果VC是精通的。应该一下子可以分析出包结构。
Python也是最近才支持的。我真的怀疑Ruby的未来。我下的版本当时还没有支持。
在EXCEL中使用只要在单元格中输入简单的公式就行{=TA_EMA( A1:A200, 13 )}//我没有测试过