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 
34 /* List of contributors:
35  *
36  *  Initial  Name/description
37  *  -------------------------------------------------------------------
38  *  MF       Mario Fortier
39  *  AA       Andrew Atkinson
40  *
41  * Change history:
42  *
43  *  MMDDYY BY   Description
44  *  -------------------------------------------------------------------
45  *  112400 MF   Template creation.
46  *  052603 MF   Adapt code to compile with .NET Managed C++
47  *  062804 MF   Resolve div by zero bug on limit case.
48  *  020605 AA   Fix #1117666 Lookback & out-of-bound bug.
49  */
50 
51 /**** START GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/
52 /* All code within this section is automatically
53  * generated by gen_code. Any modification will be lost
54  * next time gen_code is run.
55  */
56 /* Generated */
57 /* Generated */ #if defined( _MANAGED )
58 /* Generated */    #include "TA-Lib-Core.h"
59 /* Generated */    #define TA_INTERNAL_ERROR(Id) (RetCode::InternalError)
60 /* Generated */    namespace TicTacTec { namespace TA { namespace Library {
61 /* Generated */ #elif defined( _JAVA )
62 /* Generated */    #include "ta_defs.h"
63 /* Generated */    #include "ta_java_defs.h"
64 /* Generated */    #define TA_INTERNAL_ERROR(Id) (RetCode.InternalError)
65 /* Generated */ #else
66 /* Generated */    #include <string.h>
67 /* Generated */    #include <math.h>
68 /* Generated */    #include "ta_func.h"
69 /* Generated */ #endif
70 /* Generated */
71 /* Generated */ #ifndef TA_UTILITY_H
72 /* Generated */    #include "ta_utility.h"
73 /* Generated */ #endif
74 /* Generated */
75 /* Generated */ #ifndef TA_MEMORY_H
76 /* Generated */    #include "ta_memory.h"
77 /* Generated */ #endif
78 /* Generated */
79 /* Generated */ #define TA_PREFIX(x) TA_##x
80 /* Generated */ #define INPUT_TYPE   double
81 /* Generated */
82 /* Generated */ #if defined( _MANAGED )
ApoLookback(int optInFastPeriod,int optInSlowPeriod,MAType optInMAType)83 /* Generated */ int Core::ApoLookback( int           optInFastPeriod, /* From 2 to 100000 */
84 /* Generated */                      int           optInSlowPeriod, /* From 2 to 100000 */
85 /* Generated */                      MAType        optInMAType ) /* Generated */
86 /* Generated */ #elif defined( _JAVA )
87 /* Generated */ public int apoLookback( int           optInFastPeriod, /* From 2 to 100000 */
88 /* Generated */                       int           optInSlowPeriod, /* From 2 to 100000 */
89 /* Generated */                       MAType        optInMAType ) /* Generated */
90 /* Generated */ #else
91 /* Generated */ int TA_APO_Lookback( int           optInFastPeriod, /* From 2 to 100000 */
92 /* Generated */                    int           optInSlowPeriod, /* From 2 to 100000 */
93 /* Generated */                    TA_MAType     optInMAType ) /* Generated */
94 /* Generated */ #endif
95 /**** END GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/
96 {
97    /* insert local variable here */
98 
99 /**** START GENCODE SECTION 2 - DO NOT DELETE THIS LINE ****/
100 /* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK
101 /* Generated */    /* min/max are checked for optInFastPeriod. */
102 /* Generated */    if( (int)optInFastPeriod == TA_INTEGER_DEFAULT )
103 /* Generated */       optInFastPeriod = 12;
104 /* Generated */    else if( ((int)optInFastPeriod < 2) || ((int)optInFastPeriod > 100000) )
105 /* Generated */       return -1;
106 /* Generated */
107 /* Generated */    /* min/max are checked for optInSlowPeriod. */
108 /* Generated */    if( (int)optInSlowPeriod == TA_INTEGER_DEFAULT )
109 /* Generated */       optInSlowPeriod = 26;
110 /* Generated */    else if( ((int)optInSlowPeriod < 2) || ((int)optInSlowPeriod > 100000) )
111 /* Generated */       return -1;
112 /* Generated */
113 /* Generated */    #if !defined(_MANAGED) && !defined(_JAVA)
114 /* Generated */    if( (int)optInMAType == TA_INTEGER_DEFAULT )
115 /* Generated */       optInMAType = (TA_MAType)0;
116 /* Generated */    else if( ((int)optInMAType < 0) || ((int)optInMAType > 8) )
117 /* Generated */       return -1;
118 /* Generated */
119 /* Generated */    #endif /* !defined(_MANAGED) && !defined(_JAVA)*/
120 /* Generated */ #endif /* TA_FUNC_NO_RANGE_CHECK */
121 /**** END GENCODE SECTION 2 - DO NOT DELETE THIS LINE ****/
122 
123    /* insert lookback code here. */
124 
125    /* The slow MA is the key factor determining the lookback period. */
126    return LOOKBACK_CALL(MA)( max(optInSlowPeriod,optInFastPeriod), optInMAType );
127 }
128 
129 
130 /**** START GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/
131 /*
132  * TA_APO - Absolute Price Oscillator
133  *
134  * Input  = double
135  * Output = double
136  *
137  * Optional Parameters
138  * -------------------
139  * optInFastPeriod:(From 2 to 100000)
140  *    Number of period for the fast MA
141  *
142  * optInSlowPeriod:(From 2 to 100000)
143  *    Number of period for the slow MA
144  *
145  * optInMAType:
146  *    Type of Moving Average
147  *
148  *
149  */
150 /* Generated */
151 /* Generated */ #if defined( _MANAGED ) && defined( USE_SUBARRAY )
152 /* Generated */ enum class Core::RetCode Core::Apo( int    startIdx,
153 /* Generated */                                     int    endIdx,
154 /* Generated */                                     SubArray^    inReal,
155 /* Generated */                                     int           optInFastPeriod, /* From 2 to 100000 */
156 /* Generated */                                     int           optInSlowPeriod, /* From 2 to 100000 */
157 /* Generated */                                     MAType        optInMAType,
158 /* Generated */                                     [Out]int%    outBegIdx,
159 /* Generated */                                     [Out]int%    outNBElement,
160 /* Generated */                                     cli::array<double>^  outReal )
161 /* Generated */ #elif defined( _MANAGED )
162 /* Generated */ enum class Core::RetCode Core::Apo( int    startIdx,
163 /* Generated */                                     int    endIdx,
164 /* Generated */                                     cli::array<double>^ inReal,
165 /* Generated */                                     int           optInFastPeriod, /* From 2 to 100000 */
166 /* Generated */                                     int           optInSlowPeriod, /* From 2 to 100000 */
167 /* Generated */                                     MAType        optInMAType,
168 /* Generated */                                     [Out]int%    outBegIdx,
169 /* Generated */                                     [Out]int%    outNBElement,
170 /* Generated */                                     cli::array<double>^  outReal )
171 /* Generated */ #elif defined( _JAVA )
172 /* Generated */ public RetCode apo( int    startIdx,
173 /* Generated */                     int    endIdx,
174 /* Generated */                     double       inReal[],
175 /* Generated */                     int           optInFastPeriod, /* From 2 to 100000 */
176 /* Generated */                     int           optInSlowPeriod, /* From 2 to 100000 */
177 /* Generated */                     MAType        optInMAType,
178 /* Generated */                     MInteger     outBegIdx,
179 /* Generated */                     MInteger     outNBElement,
180 /* Generated */                     double        outReal[] )
181 /* Generated */ #else
182 /* Generated */ TA_RetCode TA_APO( int    startIdx,
183 /* Generated */                    int    endIdx,
184 /* Generated */                    const double inReal[],
185 /* Generated */                    int           optInFastPeriod, /* From 2 to 100000 */
186 /* Generated */                    int           optInSlowPeriod, /* From 2 to 100000 */
187 /* Generated */                    TA_MAType     optInMAType,
188 /* Generated */                    int          *outBegIdx,
189 /* Generated */                    int          *outNBElement,
190 /* Generated */                    double        outReal[] )
191 /* Generated */ #endif
192 /**** END GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/
193 {
194    /* Insert local variables here. */
195    ARRAY_REF(tempBuffer);
196    ENUM_DECLARATION(RetCode) retCode;
197 
198 /**** START GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/
199 /* Generated */
200 /* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK
201 /* Generated */
202 /* Generated */    /* Validate the requested output range. */
203 /* Generated */    if( startIdx < 0 )
204 /* Generated */       return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_START_INDEX,OutOfRangeStartIndex);
205 /* Generated */    if( (endIdx < 0) || (endIdx < startIdx))
206 /* Generated */       return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_END_INDEX,OutOfRangeEndIndex);
207 /* Generated */
208 /* Generated */    #if !defined(_JAVA)
209 /* Generated */    if( !inReal ) return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
210 /* Generated */    #endif /* !defined(_JAVA)*/
211 /* Generated */    /* min/max are checked for optInFastPeriod. */
212 /* Generated */    if( (int)optInFastPeriod == TA_INTEGER_DEFAULT )
213 /* Generated */       optInFastPeriod = 12;
214 /* Generated */    else if( ((int)optInFastPeriod < 2) || ((int)optInFastPeriod > 100000) )
215 /* Generated */       return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
216 /* Generated */
217 /* Generated */    /* min/max are checked for optInSlowPeriod. */
218 /* Generated */    if( (int)optInSlowPeriod == TA_INTEGER_DEFAULT )
219 /* Generated */       optInSlowPeriod = 26;
220 /* Generated */    else if( ((int)optInSlowPeriod < 2) || ((int)optInSlowPeriod > 100000) )
221 /* Generated */       return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
222 /* Generated */
223 /* Generated */    #if !defined(_MANAGED) && !defined(_JAVA)
224 /* Generated */    if( (int)optInMAType == TA_INTEGER_DEFAULT )
225 /* Generated */       optInMAType = (TA_MAType)0;
226 /* Generated */    else if( ((int)optInMAType < 0) || ((int)optInMAType > 8) )
227 /* Generated */       return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
228 /* Generated */
229 /* Generated */    #endif /* !defined(_MANAGED) && !defined(_JAVA)*/
230 /* Generated */    #if !defined(_JAVA)
231 /* Generated */    if( !outReal )
232 /* Generated */       return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
233 /* Generated */
234 /* Generated */    #endif /* !defined(_JAVA) */
235 /* Generated */ #endif /* TA_FUNC_NO_RANGE_CHECK */
236 /* Generated */
237 /**** END GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/
238 
239    /* Insert TA function code here. */
240 
241    /* Allocate an intermediate buffer. */
242    ARRAY_ALLOC(tempBuffer, (endIdx-startIdx+1) );
243    #if !defined(_JAVA)
244       if( !tempBuffer )
245          return ENUM_VALUE(RetCode,TA_ALLOC_ERR,AllocErr);
246    #endif
247 
248    retCode = FUNCTION_CALL(INT_PO)( startIdx, endIdx,
249                                     inReal,
250                                     optInFastPeriod,
251                                     optInSlowPeriod,
252                                     optInMAType,
253                                     outBegIdx,
254                                     outNBElement,
255                                     outReal,
256                                     tempBuffer,
257                                     0 /* No percentage. */ );
258 
259    ARRAY_FREE( tempBuffer );
260 
261    return retCode;
262 }
263 
264 /* Internal price oscillator function.
265  *
266  * A buffer must be provided for intermediate processing.
267  */
268 #if defined( _MANAGED ) && defined( USE_SUBARRAY ) && !defined( USE_SINGLE_PRECISION_INPUT )
269  enum class Core::RetCode Core::TA_INT_PO( int    startIdx,
270                                            int    endIdx,
271 									       SubArray^ inReal,
272                                            int    optInFastPeriod,
273                                            int    optInSlowPeriod,
274 										   MAType    optInMethod_2,
275                                            [Out]int% outBegIdx,
276                                            [Out]int% outNBElement,
277 										   cli::array<double>^ outReal,
278                                            cli::array<double>^ tempBuffer,
279                                            int  doPercentageOutput )
280 
281 #elif defined( _MANAGED )
282  enum class Core::RetCode Core::TA_INT_PO( int    startIdx,
283                                            int    endIdx,
284 									       cli::array<INPUT_TYPE>^ inReal,
285                                            int    optInFastPeriod,
286                                            int    optInSlowPeriod,
287 										   MAType    optInMethod_2,
288                                            [Out]int% outBegIdx,
289                                            [Out]int% outNBElement,
290 										   cli::array<double>^ outReal,
291                                            cli::array<double>^ tempBuffer,
292                                            int  doPercentageOutput )
293 #elif defined( _JAVA )
294 RetCode TA_INT_PO( int        startIdx,
295                    int        endIdx,
296                    INPUT_TYPE inReal[],
297                    int        optInFastPeriod,
298                    int        optInSlowPeriod,
299                    MAType  optInMethod_2,
300                    MInteger   outBegIdx,
301                    MInteger   outNBElement,
302                    double     outReal[],
303                    double     tempBuffer[],
304                    int        doPercentageOutput )
305 
306 #else
307 TA_RetCode TA_PREFIX(INT_PO)( int    startIdx,
308                               int    endIdx,
309                               const INPUT_TYPE *inReal,
310                               int    optInFastPeriod,
311                               int    optInSlowPeriod,
312                               TA_MAType optInMethod_2,
313                               int   *outBegIdx,
314                               int   *outNBElement,
315                               double      *outReal,
316                               double      *tempBuffer,
317                               int  doPercentageOutput )
318 #endif
319 {
320    ENUM_DECLARATION(RetCode) retCode;
321 
322    double tempReal;
323    int tempInteger;
324    VALUE_HANDLE_INT(outBegIdx1);
325    VALUE_HANDLE_INT(outNbElement1);
326    VALUE_HANDLE_INT(outBegIdx2);
327    VALUE_HANDLE_INT(outNbElement2);
328 
329    int i, j;
330 
331    /* Make sure slow is really slower than
332     * the fast period! if not, swap...
333     */
334    if( optInSlowPeriod < optInFastPeriod )
335    {
336        /* swap */
337        tempInteger     = optInSlowPeriod;
338        optInSlowPeriod = optInFastPeriod;
339        optInFastPeriod = tempInteger;
340    }
341 
342    /* Calculate the fast MA into the tempBuffer. */
343    retCode = FUNCTION_CALL(MA)( startIdx, endIdx,
344                                 inReal,
345                                 optInFastPeriod,
346                                 optInMethod_2,
347                                 VALUE_HANDLE_OUT(outBegIdx2), VALUE_HANDLE_OUT(outNbElement2),
348 							    tempBuffer );
349 
350    if( retCode == ENUM_VALUE(RetCode,TA_SUCCESS,Success) )
351    {
352       /* Calculate the slow MA into the output. */
353       retCode = FUNCTION_CALL(MA)( startIdx, endIdx,
354                                    inReal,
355                                    optInSlowPeriod,
356                                    optInMethod_2,
357                                    VALUE_HANDLE_OUT(outBegIdx1), VALUE_HANDLE_OUT(outNbElement1),
358 							       outReal );
359 
360       if( retCode == ENUM_VALUE(RetCode,TA_SUCCESS,Success) )
361       {
362          tempInteger = VALUE_HANDLE_GET(outBegIdx1) - VALUE_HANDLE_GET(outBegIdx2);
363          if( doPercentageOutput != 0 )
364          {
365             /* Calculate ((fast MA)-(slow MA))/(slow MA) in the output. */
366             for( i=0,j=tempInteger; i < VALUE_HANDLE_GET(outNbElement1); i++, j++ )
367             {
368                tempReal = outReal[i];
369                if( !TA_IS_ZERO(tempReal) )
370                   outReal[i] = ((tempBuffer[j]-tempReal)/tempReal)*100.0;
371                else
372                   outReal[i] = 0.0;
373             }
374          }
375          else
376          {
377             /* Calculate (fast MA)-(slow MA) in the output. */
378             for( i=0,j=tempInteger; i < VALUE_HANDLE_GET(outNbElement1); i++, j++ )
379                outReal[i] = tempBuffer[j]-outReal[i];
380          }
381 
382          VALUE_HANDLE_DEREF(outBegIdx)     = VALUE_HANDLE_GET(outBegIdx1);
383          VALUE_HANDLE_DEREF(outNBElement)  = VALUE_HANDLE_GET(outNbElement1);
384       }
385    }
386 
387    if( retCode != ENUM_VALUE(RetCode,TA_SUCCESS,Success) )
388    {
389       VALUE_HANDLE_DEREF_TO_ZERO(outBegIdx);
390       VALUE_HANDLE_DEREF_TO_ZERO(outNBElement);
391    }
392 
393    return retCode;
394 }
395 
396 /**** START GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/
397 /* Generated */
398 /* Generated */ #define  USE_SINGLE_PRECISION_INPUT
399 /* Generated */ #if !defined( _MANAGED ) && !defined( _JAVA )
400 /* Generated */    #undef   TA_PREFIX
401 /* Generated */    #define  TA_PREFIX(x) TA_S_##x
402 /* Generated */ #endif
403 /* Generated */ #undef   INPUT_TYPE
404 /* Generated */ #define  INPUT_TYPE float
405 /* Generated */ #if defined( _MANAGED )
406 /* Generated */ enum class Core::RetCode Core::Apo( int    startIdx,
407 /* Generated */                                     int    endIdx,
408 /* Generated */                                     cli::array<float>^ inReal,
409 /* Generated */                                     int           optInFastPeriod, /* From 2 to 100000 */
410 /* Generated */                                     int           optInSlowPeriod, /* From 2 to 100000 */
411 /* Generated */                                     MAType        optInMAType,
412 /* Generated */                                     [Out]int%    outBegIdx,
413 /* Generated */                                     [Out]int%    outNBElement,
414 /* Generated */                                     cli::array<double>^  outReal )
415 /* Generated */ #elif defined( _JAVA )
416 /* Generated */ public RetCode apo( int    startIdx,
417 /* Generated */                     int    endIdx,
418 /* Generated */                     float        inReal[],
419 /* Generated */                     int           optInFastPeriod, /* From 2 to 100000 */
420 /* Generated */                     int           optInSlowPeriod, /* From 2 to 100000 */
421 /* Generated */                     MAType        optInMAType,
422 /* Generated */                     MInteger     outBegIdx,
423 /* Generated */                     MInteger     outNBElement,
424 /* Generated */                     double        outReal[] )
425 /* Generated */ #else
426 /* Generated */ TA_RetCode TA_S_APO( int    startIdx,
427 /* Generated */                      int    endIdx,
428 /* Generated */                      const float  inReal[],
429 /* Generated */                      int           optInFastPeriod, /* From 2 to 100000 */
430 /* Generated */                      int           optInSlowPeriod, /* From 2 to 100000 */
431 /* Generated */                      TA_MAType     optInMAType,
432 /* Generated */                      int          *outBegIdx,
433 /* Generated */                      int          *outNBElement,
434 /* Generated */                      double        outReal[] )
435 /* Generated */ #endif
436 /* Generated */ {
437 /* Generated */    ARRAY_REF(tempBuffer);
438 /* Generated */    ENUM_DECLARATION(RetCode) retCode;
439 /* Generated */  #ifndef TA_FUNC_NO_RANGE_CHECK
440 /* Generated */     if( startIdx < 0 )
441 /* Generated */        return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_START_INDEX,OutOfRangeStartIndex);
442 /* Generated */     if( (endIdx < 0) || (endIdx < startIdx))
443 /* Generated */        return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_END_INDEX,OutOfRangeEndIndex);
444 /* Generated */     #if !defined(_JAVA)
445 /* Generated */     if( !inReal ) return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
446 /* Generated */     #endif
447 /* Generated */     if( (int)optInFastPeriod == TA_INTEGER_DEFAULT )
448 /* Generated */        optInFastPeriod = 12;
449 /* Generated */     else if( ((int)optInFastPeriod < 2) || ((int)optInFastPeriod > 100000) )
450 /* Generated */        return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
451 /* Generated */     if( (int)optInSlowPeriod == TA_INTEGER_DEFAULT )
452 /* Generated */        optInSlowPeriod = 26;
453 /* Generated */     else if( ((int)optInSlowPeriod < 2) || ((int)optInSlowPeriod > 100000) )
454 /* Generated */        return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
455 /* Generated */     #if !defined(_MANAGED) && !defined(_JAVA)
456 /* Generated */     if( (int)optInMAType == TA_INTEGER_DEFAULT )
457 /* Generated */        optInMAType = (TA_MAType)0;
458 /* Generated */     else if( ((int)optInMAType < 0) || ((int)optInMAType > 8) )
459 /* Generated */        return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
460 /* Generated */     #endif
461 /* Generated */     #if !defined(_JAVA)
462 /* Generated */     if( !outReal )
463 /* Generated */        return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
464 /* Generated */     #endif
465 /* Generated */  #endif
466 /* Generated */    ARRAY_ALLOC(tempBuffer, (endIdx-startIdx+1) );
467 /* Generated */    #if !defined(_JAVA)
468 /* Generated */       if( !tempBuffer )
469 /* Generated */          return ENUM_VALUE(RetCode,TA_ALLOC_ERR,AllocErr);
470 /* Generated */    #endif
471 /* Generated */    retCode = FUNCTION_CALL(INT_PO)( startIdx, endIdx,
472 /* Generated */                                     inReal,
473 /* Generated */                                     optInFastPeriod,
474 /* Generated */                                     optInSlowPeriod,
475 /* Generated */                                     optInMAType,
476 /* Generated */                                     outBegIdx,
477 /* Generated */                                     outNBElement,
478 /* Generated */                                     outReal,
479 /* Generated */                                     tempBuffer,
480 /* Generated */                                     0  );
481 /* Generated */    ARRAY_FREE( tempBuffer );
482 /* Generated */    return retCode;
483 /* Generated */ }
484 /* Generated */ #if defined( _MANAGED ) && defined( USE_SUBARRAY ) && !defined( USE_SINGLE_PRECISION_INPUT )
485 /* Generated */  enum class Core::RetCode Core::TA_INT_PO( int    startIdx,
486 /* Generated */                                            int    endIdx,
487 /* Generated */ 									       SubArray^ inReal,
488 /* Generated */                                            int    optInFastPeriod,
489 /* Generated */                                            int    optInSlowPeriod,
490 /* Generated */ 										   MAType    optInMethod_2,
491 /* Generated */                                            [Out]int% outBegIdx,
492 /* Generated */                                            [Out]int% outNBElement,
493 /* Generated */ 										   cli::array<double>^ outReal,
494 /* Generated */                                            cli::array<double>^ tempBuffer,
495 /* Generated */                                            int  doPercentageOutput )
496 /* Generated */ #elif defined( _MANAGED )
497 /* Generated */  enum class Core::RetCode Core::TA_INT_PO( int    startIdx,
498 /* Generated */                                            int    endIdx,
499 /* Generated */ 									       cli::array<INPUT_TYPE>^ inReal,
500 /* Generated */                                            int    optInFastPeriod,
501 /* Generated */                                            int    optInSlowPeriod,
502 /* Generated */ 										   MAType    optInMethod_2,
503 /* Generated */                                            [Out]int% outBegIdx,
504 /* Generated */                                            [Out]int% outNBElement,
505 /* Generated */ 										   cli::array<double>^ outReal,
506 /* Generated */                                            cli::array<double>^ tempBuffer,
507 /* Generated */                                            int  doPercentageOutput )
508 /* Generated */ #elif defined( _JAVA )
509 /* Generated */ RetCode TA_INT_PO( int        startIdx,
510 /* Generated */                    int        endIdx,
511 /* Generated */                    INPUT_TYPE inReal[],
512 /* Generated */                    int        optInFastPeriod,
513 /* Generated */                    int        optInSlowPeriod,
514 /* Generated */                    MAType  optInMethod_2,
515 /* Generated */                    MInteger   outBegIdx,
516 /* Generated */                    MInteger   outNBElement,
517 /* Generated */                    double     outReal[],
518 /* Generated */                    double     tempBuffer[],
519 /* Generated */                    int        doPercentageOutput )
520 /* Generated */ #else
521 /* Generated */ TA_RetCode TA_PREFIX(INT_PO)( int    startIdx,
522 /* Generated */                               int    endIdx,
523 /* Generated */                               const INPUT_TYPE *inReal,
524 /* Generated */                               int    optInFastPeriod,
525 /* Generated */                               int    optInSlowPeriod,
526 /* Generated */                               TA_MAType optInMethod_2,
527 /* Generated */                               int   *outBegIdx,
528 /* Generated */                               int   *outNBElement,
529 /* Generated */                               double      *outReal,
530 /* Generated */                               double      *tempBuffer,
531 /* Generated */                               int  doPercentageOutput )
532 /* Generated */ #endif
533 /* Generated */ {
534 /* Generated */    ENUM_DECLARATION(RetCode) retCode;
535 /* Generated */    double tempReal;
536 /* Generated */    int tempInteger;
537 /* Generated */    VALUE_HANDLE_INT(outBegIdx1);
538 /* Generated */    VALUE_HANDLE_INT(outNbElement1);
539 /* Generated */    VALUE_HANDLE_INT(outBegIdx2);
540 /* Generated */    VALUE_HANDLE_INT(outNbElement2);
541 /* Generated */    int i, j;
542 /* Generated */    if( optInSlowPeriod < optInFastPeriod )
543 /* Generated */    {
544 /* Generated */        tempInteger     = optInSlowPeriod;
545 /* Generated */        optInSlowPeriod = optInFastPeriod;
546 /* Generated */        optInFastPeriod = tempInteger;
547 /* Generated */    }
548 /* Generated */    retCode = FUNCTION_CALL(MA)( startIdx, endIdx,
549 /* Generated */                                 inReal,
550 /* Generated */                                 optInFastPeriod,
551 /* Generated */                                 optInMethod_2,
552 /* Generated */                                 VALUE_HANDLE_OUT(outBegIdx2), VALUE_HANDLE_OUT(outNbElement2),
553 /* Generated */ 							    tempBuffer );
554 /* Generated */    if( retCode == ENUM_VALUE(RetCode,TA_SUCCESS,Success) )
555 /* Generated */    {
556 /* Generated */       retCode = FUNCTION_CALL(MA)( startIdx, endIdx,
557 /* Generated */                                    inReal,
558 /* Generated */                                    optInSlowPeriod,
559 /* Generated */                                    optInMethod_2,
560 /* Generated */                                    VALUE_HANDLE_OUT(outBegIdx1), VALUE_HANDLE_OUT(outNbElement1),
561 /* Generated */ 							       outReal );
562 /* Generated */       if( retCode == ENUM_VALUE(RetCode,TA_SUCCESS,Success) )
563 /* Generated */       {
564 /* Generated */          tempInteger = VALUE_HANDLE_GET(outBegIdx1) - VALUE_HANDLE_GET(outBegIdx2);
565 /* Generated */          if( doPercentageOutput != 0 )
566 /* Generated */          {
567 /* Generated */             for( i=0,j=tempInteger; i < VALUE_HANDLE_GET(outNbElement1); i++, j++ )
568 /* Generated */             {
569 /* Generated */                tempReal = outReal[i];
570 /* Generated */                if( !TA_IS_ZERO(tempReal) )
571 /* Generated */                   outReal[i] = ((tempBuffer[j]-tempReal)/tempReal)*100.0;
572 /* Generated */                else
573 /* Generated */                   outReal[i] = 0.0;
574 /* Generated */             }
575 /* Generated */          }
576 /* Generated */          else
577 /* Generated */          {
578 /* Generated */             for( i=0,j=tempInteger; i < VALUE_HANDLE_GET(outNbElement1); i++, j++ )
579 /* Generated */                outReal[i] = tempBuffer[j]-outReal[i];
580 /* Generated */          }
581 /* Generated */          VALUE_HANDLE_DEREF(outBegIdx)     = VALUE_HANDLE_GET(outBegIdx1);
582 /* Generated */          VALUE_HANDLE_DEREF(outNBElement)  = VALUE_HANDLE_GET(outNbElement1);
583 /* Generated */       }
584 /* Generated */    }
585 /* Generated */    if( retCode != ENUM_VALUE(RetCode,TA_SUCCESS,Success) )
586 /* Generated */    {
587 /* Generated */       VALUE_HANDLE_DEREF_TO_ZERO(outBegIdx);
588 /* Generated */       VALUE_HANDLE_DEREF_TO_ZERO(outNBElement);
589 /* Generated */    }
590 /* Generated */    return retCode;
591 /* Generated */ }
592 /* Generated */
593 /* Generated */ #if defined( _MANAGED )
594 /* Generated */ }}} // Close namespace TicTacTec.TA.Lib
595 /* Generated */ #endif
596 /**** END GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/
597 
598