ta_defs.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. /* TA-LIB Copyright (c) 1999-2007, Mario Fortier
  2. * All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or
  5. * without modification, are permitted provided that the following
  6. * conditions are met:
  7. *
  8. * - Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. *
  11. * - Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in
  13. * the documentation and/or other materials provided with the
  14. * distribution.
  15. *
  16. * - Neither name of author nor the names of its contributors
  17. * may be used to endorse or promote products derived from this
  18. * software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  23. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  24. * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  25. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  26. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  28. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  29. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  30. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  31. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. #ifndef TA_DEFS_H
  34. #define TA_DEFS_H
  35. /*** The following block of code is to define:
  36. ***
  37. *** UInt32 : 32 bits unsigned integer.
  38. *** Int32 : 32 bits signed integer.
  39. *** UInt64 : 64 bits unsigned integer.
  40. *** Int64 : 64 bits signed integer.
  41. ***
  42. *** INT_MIN : The minimal value for Int32
  43. *** INT_MAX : The maximal value for Int32
  44. ***/
  45. #ifndef FD_DEFS_H
  46. #if defined( _MANAGED )
  47. /* Int32, UInt32, Int64 and UInt64 are built-in for .NET */
  48. #define INT_MIN (Int32::MinValue)
  49. #define INT_MAX (Int32::MaxValue)
  50. #elif defined( _JAVA )
  51. #define INT_MIN Integer.MIN_VALUE
  52. #define INT_MAX Integer.MAX_VALUE
  53. #else
  54. #include <limits.h>
  55. /* Identify if 64 bits platform with __64BIT__.
  56. * Can also be done from compiler command line.
  57. */
  58. #if defined(_WIN64)
  59. #define __64BIT__ 1
  60. #endif
  61. #if defined( __LP64__ ) || defined( _LP64 )
  62. #define __64BIT__ 1
  63. #endif
  64. /* Check also for some known GCC def for 64 bits platform. */
  65. #if defined(__alpha__)\
  66. ||defined(__ia64__)\
  67. ||defined(__ppc64__)\
  68. ||defined(__s390x__)\
  69. ||defined(__x86_64__)
  70. #define __64BIT__ 1
  71. #endif
  72. #if !defined(__MACTYPES__)
  73. typedef signed int Int32;
  74. typedef unsigned int UInt32;
  75. #if defined(_WIN32) || defined(_WIN64)
  76. /* See "Windows Data Types". Platform SDK. MSDN documentation. */
  77. typedef signed __int64 Int64;
  78. typedef unsigned __int64 UInt64;
  79. #else
  80. #if defined(__64BIT__)
  81. /* Standard LP64 model for 64 bits Unix platform. */
  82. typedef signed long Int64;
  83. typedef unsigned long UInt64;
  84. #else
  85. /* Standard ILP32 model for 32 bits Unix platform. */
  86. typedef signed long long Int64;
  87. typedef unsigned long long UInt64;
  88. #endif
  89. #endif
  90. #endif
  91. #endif
  92. #endif
  93. /* Enumeration and macros to abstract syntax differences
  94. * between C, C++, managed C++ and Java.
  95. */
  96. #if defined( _MANAGED )
  97. /* CMJ is the "CManagedJava" macro. It allows to write variant
  98. * for the 3 different languages.
  99. */
  100. #define CMJ(c,managed,java) managed
  101. /* Enumeration abstraction */
  102. #define ENUM_BEGIN(w) enum class w {
  103. #define ENUM_DEFINE(x,y) y
  104. #define ENUM_VALUE(w,x,y) (w::y)
  105. #define ENUM_CASE(w,x,y) (w::y)
  106. #define ENUM_DECLARATION(w) w
  107. #define ENUM_END(w) };
  108. /* Structure abstraction */
  109. #define STRUCT_BEGIN(x) struct x {
  110. #define STRUCT_END(x) };
  111. /* Pointer/reference abstraction */
  112. #define VALUE_HANDLE_INT(name) int name
  113. #define VALUE_HANDLE_DEREF(name) name
  114. #define VALUE_HANDLE_DEREF_TO_ZERO(name) name = 0
  115. #define VALUE_HANDLE_OUT(name) name
  116. #define VALUE_HANDLE_GET(name) name
  117. #define VALUE_HANDLE_SET(name,x) name = x
  118. /* Misc. */
  119. #define CONSTANT_DOUBLE(x) const double x
  120. #define NAMESPACE(x) x::
  121. #define UNUSED_VARIABLE(x) (void)x
  122. #elif defined( _JAVA )
  123. #define CMJ(c,managed,java) java
  124. #define ENUM_BEGIN(w) public enum w {
  125. #define ENUM_DEFINE(x,y) y
  126. #define ENUM_VALUE(w,x,y) w.y
  127. #define ENUM_CASE(w,x,y) y
  128. #define ENUM_DECLARATION(w) w
  129. #define ENUM_END(w) };
  130. #define STRUCT_BEGIN(x) public class x {
  131. #define STRUCT_END(x) };
  132. #define VALUE_HANDLE_INT(name) MInteger name = new MInteger()
  133. #define VALUE_HANDLE_DEREF(name) name.value
  134. #define VALUE_HANDLE_DEREF_TO_ZERO(name) name.value = 0
  135. #define VALUE_HANDLE_OUT(name) name
  136. #define VALUE_HANDLE_GET(name) name.value
  137. #define VALUE_HANDLE_SET(name,x) name.value = x
  138. #define CONSTANT_DOUBLE(x) final double x
  139. #define NAMESPACE(x) x.
  140. #define UNUSED_VARIABLE(x)
  141. #else
  142. #define CMJ(c,managed,java) c
  143. #define ENUM_BEGIN(w) typedef enum {
  144. #define ENUM_DEFINE(x,y) x
  145. #define ENUM_VALUE(w,x,y) x
  146. #define ENUM_CASE(w,x,y) x
  147. #define ENUM_DECLARATION(w) TA_##w
  148. #define ENUM_END(w) } TA_##w;
  149. #define STRUCT_BEGIN(x) typedef struct {
  150. #define STRUCT_END(x) } x;
  151. #define VALUE_HANDLE_INT(name) int name
  152. #define VALUE_HANDLE_DEREF(name) (*name)
  153. #define VALUE_HANDLE_DEREF_TO_ZERO(name) (*name) = 0
  154. #define VALUE_HANDLE_OUT(name) &name
  155. #define VALUE_HANDLE_GET(name) name
  156. #define VALUE_HANDLE_SET(name,x) name = x
  157. #define CONSTANT_DOUBLE(x) const double x
  158. #define NAMESPACE(x)
  159. #define UNUSED_VARIABLE(x) (void)x
  160. #endif
  161. /* Abstraction of function calls within the library.
  162. * Needed because Java/.NET allows overloading, while for C the
  163. * TA_PREFIX allows to select variant of the same function.
  164. */
  165. #define FUNCTION_CALL(x) TA_PREFIX(x)
  166. #define FUNCTION_CALL_DOUBLE(x) TA_##x
  167. #define LOOKBACK_CALL(x) TA_##x##_Lookback
  168. /* min/max value for a TA_Integer */
  169. #define TA_INTEGER_MIN (INT_MIN+1)
  170. #define TA_INTEGER_MAX (INT_MAX)
  171. /* min/max value for a TA_Real
  172. *
  173. * Use fix value making sense in the
  174. * context of TA-Lib (avoid to use DBL_MIN
  175. * and DBL_MAX standard macro because they
  176. * are troublesome with some compiler).
  177. */
  178. #define TA_REAL_MIN (-3e+37)
  179. #define TA_REAL_MAX (3e+37)
  180. /* A value outside of the min/max range
  181. * indicates an undefined or default value.
  182. */
  183. #define TA_INTEGER_DEFAULT (INT_MIN)
  184. #define TA_REAL_DEFAULT (-4e+37)
  185. /* Part of this file is generated by gen_code */
  186. ENUM_BEGIN( RetCode )
  187. /* 0 */ ENUM_DEFINE( TA_SUCCESS, Success ), /* No error */
  188. /* 1 */ ENUM_DEFINE( TA_LIB_NOT_INITIALIZE, LibNotInitialize ), /* TA_Initialize was not sucessfully called */
  189. /* 2 */ ENUM_DEFINE( TA_BAD_PARAM, BadParam ), /* A parameter is out of range */
  190. /* 3 */ ENUM_DEFINE( TA_ALLOC_ERR, AllocErr ), /* Possibly out-of-memory */
  191. /* 4 */ ENUM_DEFINE( TA_GROUP_NOT_FOUND, GroupNotFound ),
  192. /* 5 */ ENUM_DEFINE( TA_FUNC_NOT_FOUND, FuncNotFound ),
  193. /* 6 */ ENUM_DEFINE( TA_INVALID_HANDLE, InvalidHandle ),
  194. /* 7 */ ENUM_DEFINE( TA_INVALID_PARAM_HOLDER, InvalidParamHolder ),
  195. /* 8 */ ENUM_DEFINE( TA_INVALID_PARAM_HOLDER_TYPE, InvalidParamHolderType ),
  196. /* 9 */ ENUM_DEFINE( TA_INVALID_PARAM_FUNCTION, InvalidParamFunction ),
  197. /* 10 */ ENUM_DEFINE( TA_INPUT_NOT_ALL_INITIALIZE, InputNotAllInitialize ),
  198. /* 11 */ ENUM_DEFINE( TA_OUTPUT_NOT_ALL_INITIALIZE, OutputNotAllInitialize ),
  199. /* 12 */ ENUM_DEFINE( TA_OUT_OF_RANGE_START_INDEX, OutOfRangeStartIndex ),
  200. /* 13 */ ENUM_DEFINE( TA_OUT_OF_RANGE_END_INDEX, OutOfRangeEndIndex ),
  201. /* 14 */ ENUM_DEFINE( TA_INVALID_LIST_TYPE, InvalidListType ),
  202. /* 15 */ ENUM_DEFINE( TA_BAD_OBJECT, BadObject ),
  203. /* 16 */ ENUM_DEFINE( TA_NOT_SUPPORTED, NotSupported ),
  204. /* 5000 */ ENUM_DEFINE( TA_INTERNAL_ERROR, InternalError ) = 5000,
  205. /* 0xFFFF */ ENUM_DEFINE( TA_UNKNOWN_ERR, UnknownErr ) = 0xFFFF
  206. ENUM_END( RetCode )
  207. ENUM_BEGIN( Compatibility )
  208. ENUM_DEFINE( TA_COMPATIBILITY_DEFAULT, Default ),
  209. ENUM_DEFINE( TA_COMPATIBILITY_METASTOCK, Metastock )
  210. ENUM_END( Compatibility )
  211. ENUM_BEGIN( MAType )
  212. ENUM_DEFINE( TA_MAType_SMA, Sma ) =0,
  213. ENUM_DEFINE( TA_MAType_EMA, Ema ) =1,
  214. ENUM_DEFINE( TA_MAType_WMA, Wma ) =2,
  215. ENUM_DEFINE( TA_MAType_DEMA, Dema ) =3,
  216. ENUM_DEFINE( TA_MAType_TEMA, Tema ) =4,
  217. ENUM_DEFINE( TA_MAType_TRIMA, Trima ) =5,
  218. ENUM_DEFINE( TA_MAType_KAMA, Kama ) =6,
  219. ENUM_DEFINE( TA_MAType_MAMA, Mama ) =7,
  220. ENUM_DEFINE( TA_MAType_T3, T3 ) =8
  221. ENUM_END( MAType )
  222. /**** START GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/
  223. /* Generated */
  224. /* Generated */ ENUM_BEGIN( FuncUnstId )
  225. /* Generated */ /* 000 */ ENUM_DEFINE( TA_FUNC_UNST_ADX, Adx),
  226. /* Generated */ /* 001 */ ENUM_DEFINE( TA_FUNC_UNST_ADXR, Adxr),
  227. /* Generated */ /* 002 */ ENUM_DEFINE( TA_FUNC_UNST_ATR, Atr),
  228. /* Generated */ /* 003 */ ENUM_DEFINE( TA_FUNC_UNST_CMO, Cmo),
  229. /* Generated */ /* 004 */ ENUM_DEFINE( TA_FUNC_UNST_DX, Dx),
  230. /* Generated */ /* 005 */ ENUM_DEFINE( TA_FUNC_UNST_EMA, Ema),
  231. /* Generated */ /* 006 */ ENUM_DEFINE( TA_FUNC_UNST_HT_DCPERIOD, HtDcPeriod),
  232. /* Generated */ /* 007 */ ENUM_DEFINE( TA_FUNC_UNST_HT_DCPHASE, HtDcPhase),
  233. /* Generated */ /* 008 */ ENUM_DEFINE( TA_FUNC_UNST_HT_PHASOR, HtPhasor),
  234. /* Generated */ /* 009 */ ENUM_DEFINE( TA_FUNC_UNST_HT_SINE, HtSine),
  235. /* Generated */ /* 010 */ ENUM_DEFINE( TA_FUNC_UNST_HT_TRENDLINE, HtTrendline),
  236. /* Generated */ /* 011 */ ENUM_DEFINE( TA_FUNC_UNST_HT_TRENDMODE, HtTrendMode),
  237. /* Generated */ /* 012 */ ENUM_DEFINE( TA_FUNC_UNST_KAMA, Kama),
  238. /* Generated */ /* 013 */ ENUM_DEFINE( TA_FUNC_UNST_MAMA, Mama),
  239. /* Generated */ /* 014 */ ENUM_DEFINE( TA_FUNC_UNST_MFI, Mfi),
  240. /* Generated */ /* 015 */ ENUM_DEFINE( TA_FUNC_UNST_MINUS_DI, MinusDI),
  241. /* Generated */ /* 016 */ ENUM_DEFINE( TA_FUNC_UNST_MINUS_DM, MinusDM),
  242. /* Generated */ /* 017 */ ENUM_DEFINE( TA_FUNC_UNST_NATR, Natr),
  243. /* Generated */ /* 018 */ ENUM_DEFINE( TA_FUNC_UNST_PLUS_DI, PlusDI),
  244. /* Generated */ /* 019 */ ENUM_DEFINE( TA_FUNC_UNST_PLUS_DM, PlusDM),
  245. /* Generated */ /* 020 */ ENUM_DEFINE( TA_FUNC_UNST_RSI, Rsi),
  246. /* Generated */ /* 021 */ ENUM_DEFINE( TA_FUNC_UNST_STOCHRSI, StochRsi),
  247. /* Generated */ /* 022 */ ENUM_DEFINE( TA_FUNC_UNST_T3, T3),
  248. /* Generated */ ENUM_DEFINE( TA_FUNC_UNST_ALL, FuncUnstAll),
  249. /* Generated */ ENUM_DEFINE( TA_FUNC_UNST_NONE, FuncUnstNone) = -1
  250. /* Generated */ ENUM_END( FuncUnstId )
  251. /* Generated */
  252. /**** END GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/
  253. /* The TA_RangeType enum specifies the types of range that can be considered
  254. * when to compare a part of a candle to other candles
  255. */
  256. ENUM_BEGIN( RangeType )
  257. ENUM_DEFINE( TA_RangeType_RealBody, RealBody ),
  258. ENUM_DEFINE( TA_RangeType_HighLow, HighLow ),
  259. ENUM_DEFINE( TA_RangeType_Shadows, Shadows )
  260. ENUM_END( RangeType )
  261. /* The TA_CandleSettingType enum specifies which kind of setting to consider;
  262. * the settings are based on the parts of the candle and the common words
  263. * indicating the length (short, long, very long)
  264. */
  265. ENUM_BEGIN( CandleSettingType )
  266. ENUM_DEFINE( TA_BodyLong, BodyLong ),
  267. ENUM_DEFINE( TA_BodyVeryLong, BodyVeryLong ),
  268. ENUM_DEFINE( TA_BodyShort, BodyShort ),
  269. ENUM_DEFINE( TA_BodyDoji, BodyDoji ),
  270. ENUM_DEFINE( TA_ShadowLong, ShadowLong ),
  271. ENUM_DEFINE( TA_ShadowVeryLong, ShadowVeryLong ),
  272. ENUM_DEFINE( TA_ShadowShort, ShadowShort ),
  273. ENUM_DEFINE( TA_ShadowVeryShort, ShadowVeryShort ),
  274. ENUM_DEFINE( TA_Near, Near ),
  275. ENUM_DEFINE( TA_Far, Far ),
  276. ENUM_DEFINE( TA_Equal, Equal ),
  277. ENUM_DEFINE( TA_AllCandleSettings, AllCandleSettings )
  278. ENUM_END( CandleSettingType )
  279. #endif