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  *  PP       Peter Pudaite
40  *  AA       Andrew Atkinson
41  *
42  * Change history:
43  *
44  *  MMDDYY BY   Description
45  *  -------------------------------------------------------------------
46  *  120802 MF   Template creation.
47  *  101103 PP   Initial creation of code.
48  *  112603 MF   Add independent control to the RSI period.
49  *  020605 AA   Fix #1117656. NULL pointer assignement.
50  */
51 
52 /**** START GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/
53 /* All code within this section is automatically
54  * generated by gen_code. Any modification will be lost
55  * next time gen_code is run.
56  */
57 /* Generated */
58 /* Generated */ #if defined( _MANAGED )
59 /* Generated */    #include "TA-Lib-Core.h"
60 /* Generated */    #define TA_INTERNAL_ERROR(Id) (RetCode::InternalError)
61 /* Generated */    namespace TicTacTec { namespace TA { namespace Library {
62 /* Generated */ #elif defined( _JAVA )
63 /* Generated */    #include "ta_defs.h"
64 /* Generated */    #include "ta_java_defs.h"
65 /* Generated */    #define TA_INTERNAL_ERROR(Id) (RetCode.InternalError)
66 /* Generated */ #else
67 /* Generated */    #include <string.h>
68 /* Generated */    #include <math.h>
69 /* Generated */    #include "ta_func.h"
70 /* Generated */ #endif
71 /* Generated */
72 /* Generated */ #ifndef TA_UTILITY_H
73 /* Generated */    #include "ta_utility.h"
74 /* Generated */ #endif
75 /* Generated */
76 /* Generated */ #ifndef TA_MEMORY_H
77 /* Generated */    #include "ta_memory.h"
78 /* Generated */ #endif
79 /* Generated */
80 /* Generated */ #define TA_PREFIX(x) TA_##x
81 /* Generated */ #define INPUT_TYPE   double
82 /* Generated */
83 /* Generated */ #if defined( _MANAGED )
StochRsiLookback(int optInTimePeriod,int optInFastK_Period,int optInFastD_Period,MAType optInFastD_MAType)84 /* Generated */ int Core::StochRsiLookback( int           optInTimePeriod, /* From 2 to 100000 */
85 /* Generated */                           int           optInFastK_Period, /* From 1 to 100000 */
86 /* Generated */                           int           optInFastD_Period, /* From 1 to 100000 */
87 /* Generated */                           MAType        optInFastD_MAType ) /* Generated */
88 /* Generated */ #elif defined( _JAVA )
89 /* Generated */ public int stochRsiLookback( int           optInTimePeriod, /* From 2 to 100000 */
90 /* Generated */                            int           optInFastK_Period, /* From 1 to 100000 */
91 /* Generated */                            int           optInFastD_Period, /* From 1 to 100000 */
92 /* Generated */                            MAType        optInFastD_MAType ) /* Generated */
93 /* Generated */ #else
94 /* Generated */ int TA_STOCHRSI_Lookback( int           optInTimePeriod, /* From 2 to 100000 */
95 /* Generated */                         int           optInFastK_Period, /* From 1 to 100000 */
96 /* Generated */                         int           optInFastD_Period, /* From 1 to 100000 */
97 /* Generated */                         TA_MAType     optInFastD_MAType ) /* Generated */
98 /* Generated */ #endif
99 /**** END GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/
100 {
101    /* insert local variable here */
102    int retValue;
103 
104 /**** START GENCODE SECTION 2 - DO NOT DELETE THIS LINE ****/
105 /* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK
106 /* Generated */    /* min/max are checked for optInTimePeriod. */
107 /* Generated */    if( (int)optInTimePeriod == TA_INTEGER_DEFAULT )
108 /* Generated */       optInTimePeriod = 14;
109 /* Generated */    else if( ((int)optInTimePeriod < 2) || ((int)optInTimePeriod > 100000) )
110 /* Generated */       return -1;
111 /* Generated */
112 /* Generated */    /* min/max are checked for optInFastK_Period. */
113 /* Generated */    if( (int)optInFastK_Period == TA_INTEGER_DEFAULT )
114 /* Generated */       optInFastK_Period = 5;
115 /* Generated */    else if( ((int)optInFastK_Period < 1) || ((int)optInFastK_Period > 100000) )
116 /* Generated */       return -1;
117 /* Generated */
118 /* Generated */    /* min/max are checked for optInFastD_Period. */
119 /* Generated */    if( (int)optInFastD_Period == TA_INTEGER_DEFAULT )
120 /* Generated */       optInFastD_Period = 3;
121 /* Generated */    else if( ((int)optInFastD_Period < 1) || ((int)optInFastD_Period > 100000) )
122 /* Generated */       return -1;
123 /* Generated */
124 /* Generated */    #if !defined(_MANAGED) && !defined(_JAVA)
125 /* Generated */    if( (int)optInFastD_MAType == TA_INTEGER_DEFAULT )
126 /* Generated */       optInFastD_MAType = (TA_MAType)0;
127 /* Generated */    else if( ((int)optInFastD_MAType < 0) || ((int)optInFastD_MAType > 8) )
128 /* Generated */       return -1;
129 /* Generated */
130 /* Generated */    #endif /* !defined(_MANAGED) && !defined(_JAVA)*/
131 /* Generated */ #endif /* TA_FUNC_NO_RANGE_CHECK */
132 /**** END GENCODE SECTION 2 - DO NOT DELETE THIS LINE ****/
133 
134    /* insert lookback code here. */
135    retValue = LOOKBACK_CALL(RSI)( optInTimePeriod ) + LOOKBACK_CALL(STOCHF)( optInFastK_Period, optInFastD_Period, optInFastD_MAType );
136 
137    return retValue;
138 }
139 
140 /**** START GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/
141 /*
142  * TA_STOCHRSI - Stochastic Relative Strength Index
143  *
144  * Input  = double
145  * Output = double, double
146  *
147  * Optional Parameters
148  * -------------------
149  * optInTimePeriod:(From 2 to 100000)
150  *    Number of period
151  *
152  * optInFastK_Period:(From 1 to 100000)
153  *    Time period for building the Fast-K line
154  *
155  * optInFastD_Period:(From 1 to 100000)
156  *    Smoothing for making the Fast-D line. Usually set to 3
157  *
158  * optInFastD_MAType:
159  *    Type of Moving Average for Fast-D
160  *
161  *
162  */
163 /* Generated */
164 /* Generated */ #if defined( _MANAGED ) && defined( USE_SUBARRAY )
165 /* Generated */ enum class Core::RetCode Core::StochRsi( int    startIdx,
166 /* Generated */                                          int    endIdx,
167 /* Generated */                                          SubArray^    inReal,
168 /* Generated */                                          int           optInTimePeriod, /* From 2 to 100000 */
169 /* Generated */                                          int           optInFastK_Period, /* From 1 to 100000 */
170 /* Generated */                                          int           optInFastD_Period, /* From 1 to 100000 */
171 /* Generated */                                          MAType        optInFastD_MAType,
172 /* Generated */                                          [Out]int%    outBegIdx,
173 /* Generated */                                          [Out]int%    outNBElement,
174 /* Generated */                                          cli::array<double>^  outFastK,
175 /* Generated */                                          cli::array<double>^  outFastD )
176 /* Generated */ #elif defined( _MANAGED )
177 /* Generated */ enum class Core::RetCode Core::StochRsi( int    startIdx,
178 /* Generated */                                          int    endIdx,
179 /* Generated */                                          cli::array<double>^ inReal,
180 /* Generated */                                          int           optInTimePeriod, /* From 2 to 100000 */
181 /* Generated */                                          int           optInFastK_Period, /* From 1 to 100000 */
182 /* Generated */                                          int           optInFastD_Period, /* From 1 to 100000 */
183 /* Generated */                                          MAType        optInFastD_MAType,
184 /* Generated */                                          [Out]int%    outBegIdx,
185 /* Generated */                                          [Out]int%    outNBElement,
186 /* Generated */                                          cli::array<double>^  outFastK,
187 /* Generated */                                          cli::array<double>^  outFastD )
188 /* Generated */ #elif defined( _JAVA )
189 /* Generated */ public RetCode stochRsi( int    startIdx,
190 /* Generated */                          int    endIdx,
191 /* Generated */                          double       inReal[],
192 /* Generated */                          int           optInTimePeriod, /* From 2 to 100000 */
193 /* Generated */                          int           optInFastK_Period, /* From 1 to 100000 */
194 /* Generated */                          int           optInFastD_Period, /* From 1 to 100000 */
195 /* Generated */                          MAType        optInFastD_MAType,
196 /* Generated */                          MInteger     outBegIdx,
197 /* Generated */                          MInteger     outNBElement,
198 /* Generated */                          double        outFastK[],
199 /* Generated */                          double        outFastD[] )
200 /* Generated */ #else
201 /* Generated */ TA_RetCode TA_STOCHRSI( int    startIdx,
202 /* Generated */                         int    endIdx,
203 /* Generated */                         const double inReal[],
204 /* Generated */                         int           optInTimePeriod, /* From 2 to 100000 */
205 /* Generated */                         int           optInFastK_Period, /* From 1 to 100000 */
206 /* Generated */                         int           optInFastD_Period, /* From 1 to 100000 */
207 /* Generated */                         TA_MAType     optInFastD_MAType,
208 /* Generated */                         int          *outBegIdx,
209 /* Generated */                         int          *outNBElement,
210 /* Generated */                         double        outFastK[],
211 /* Generated */                         double        outFastD[] )
212 /* Generated */ #endif
213 /**** END GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/
214 {
215    /* insert local variable here */
216    ARRAY_REF(tempRSIBuffer);
217 
218    ENUM_DECLARATION(RetCode) retCode;
219    int lookbackTotal, lookbackSTOCHF, tempArraySize;
220    VALUE_HANDLE_INT(outBegIdx1);
221    VALUE_HANDLE_INT(outBegIdx2);
222    VALUE_HANDLE_INT(outNbElement1);
223 
224 /**** START GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/
225 /* Generated */
226 /* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK
227 /* Generated */
228 /* Generated */    /* Validate the requested output range. */
229 /* Generated */    if( startIdx < 0 )
230 /* Generated */       return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_START_INDEX,OutOfRangeStartIndex);
231 /* Generated */    if( (endIdx < 0) || (endIdx < startIdx))
232 /* Generated */       return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_END_INDEX,OutOfRangeEndIndex);
233 /* Generated */
234 /* Generated */    #if !defined(_JAVA)
235 /* Generated */    if( !inReal ) return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
236 /* Generated */    #endif /* !defined(_JAVA)*/
237 /* Generated */    /* min/max are checked for optInTimePeriod. */
238 /* Generated */    if( (int)optInTimePeriod == TA_INTEGER_DEFAULT )
239 /* Generated */       optInTimePeriod = 14;
240 /* Generated */    else if( ((int)optInTimePeriod < 2) || ((int)optInTimePeriod > 100000) )
241 /* Generated */       return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
242 /* Generated */
243 /* Generated */    /* min/max are checked for optInFastK_Period. */
244 /* Generated */    if( (int)optInFastK_Period == TA_INTEGER_DEFAULT )
245 /* Generated */       optInFastK_Period = 5;
246 /* Generated */    else if( ((int)optInFastK_Period < 1) || ((int)optInFastK_Period > 100000) )
247 /* Generated */       return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
248 /* Generated */
249 /* Generated */    /* min/max are checked for optInFastD_Period. */
250 /* Generated */    if( (int)optInFastD_Period == TA_INTEGER_DEFAULT )
251 /* Generated */       optInFastD_Period = 3;
252 /* Generated */    else if( ((int)optInFastD_Period < 1) || ((int)optInFastD_Period > 100000) )
253 /* Generated */       return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
254 /* Generated */
255 /* Generated */    #if !defined(_MANAGED) && !defined(_JAVA)
256 /* Generated */    if( (int)optInFastD_MAType == TA_INTEGER_DEFAULT )
257 /* Generated */       optInFastD_MAType = (TA_MAType)0;
258 /* Generated */    else if( ((int)optInFastD_MAType < 0) || ((int)optInFastD_MAType > 8) )
259 /* Generated */       return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
260 /* Generated */
261 /* Generated */    #endif /* !defined(_MANAGED) && !defined(_JAVA)*/
262 /* Generated */    #if !defined(_JAVA)
263 /* Generated */    if( !outFastK )
264 /* Generated */       return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
265 /* Generated */
266 /* Generated */    if( !outFastD )
267 /* Generated */       return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
268 /* Generated */
269 /* Generated */    #endif /* !defined(_JAVA) */
270 /* Generated */ #endif /* TA_FUNC_NO_RANGE_CHECK */
271 /* Generated */
272 /**** END GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/
273 
274    /* Insert TA function code here. */
275 
276    /* Stochastic RSI
277     *
278     * Reference: "Stochastic RSI and Dynamic Momentum Index"
279     *            by Tushar Chande and Stanley Kroll
280     *            Stock&Commodities V.11:5 (189-199)
281     *
282     * The TA-Lib version offer flexibility beyond what is explain
283     * in the Stock&Commodities article.
284     *
285     * To calculate the "Unsmoothed stochastic RSI" with symetry like
286     * explain in the article, keep the optInTimePeriod and optInFastK_Period
287     * equal. Example:
288     *
289     *    unsmoothed stoch RSI 14 : optInTimePeriod   = 14
290     *                              optInFastK_Period = 14
291     *                              optInFastD_Period = 'x'
292     *
293     * The outFastK is the unsmoothed RSI discuss in the article.
294     *
295     * You can set the optInFastD_Period to smooth the RSI. The smooth
296     * version will be found in outFastD. The outFastK will still contain
297     * the unsmoothed stoch RSI. If you do not care about the smoothing of
298     * the StochRSI, just leave optInFastD_Period to 1 and ignore outFastD.
299     */
300 
301    VALUE_HANDLE_DEREF_TO_ZERO(outBegIdx);
302    VALUE_HANDLE_DEREF_TO_ZERO(outNBElement);
303 
304    /* Adjust startIdx to account for the lookback period. */
305    lookbackSTOCHF  = LOOKBACK_CALL(STOCHF)( optInFastK_Period, optInFastD_Period, optInFastD_MAType );
306    lookbackTotal   = LOOKBACK_CALL(RSI)( optInTimePeriod ) + lookbackSTOCHF;
307 
308    if( startIdx < lookbackTotal )
309       startIdx = lookbackTotal;
310 
311    /* Make sure there is still something to evaluate. */
312    if( startIdx > endIdx )
313    {
314       VALUE_HANDLE_DEREF_TO_ZERO(outBegIdx);
315       VALUE_HANDLE_DEREF_TO_ZERO(outNBElement);
316       return ENUM_VALUE(RetCode,TA_SUCCESS,Success);
317    }
318 
319    VALUE_HANDLE_DEREF(outBegIdx) = startIdx;
320 
321    tempArraySize = (endIdx - startIdx) + 1 + lookbackSTOCHF;
322 
323    ARRAY_ALLOC( tempRSIBuffer, tempArraySize );
324 
325    retCode = FUNCTION_CALL(RSI)(startIdx-lookbackSTOCHF,
326                                 endIdx,
327                                 inReal,
328                                 optInTimePeriod,
329                                 VALUE_HANDLE_OUT(outBegIdx1),
330                                 VALUE_HANDLE_OUT(outNbElement1),
331                                 tempRSIBuffer);
332 
333    if( retCode != ENUM_VALUE(RetCode,TA_SUCCESS,Success) || VALUE_HANDLE_GET(outNbElement1) == 0 )
334    {
335       ARRAY_FREE( tempRSIBuffer );
336       VALUE_HANDLE_DEREF_TO_ZERO(outBegIdx);
337       VALUE_HANDLE_DEREF_TO_ZERO(outNBElement);
338       return retCode;
339    }
340 
341    retCode = FUNCTION_CALL_DOUBLE(STOCHF)(0,
342                                           tempArraySize-1,
343                                           tempRSIBuffer,
344                                           tempRSIBuffer,
345                                           tempRSIBuffer,
346                                           optInFastK_Period,
347                                           optInFastD_Period,
348                                           optInFastD_MAType,
349                                           VALUE_HANDLE_OUT(outBegIdx2),
350                                           outNBElement,
351                                           outFastK,
352                                           outFastD);
353 
354    ARRAY_FREE( tempRSIBuffer );
355 
356    if( retCode != ENUM_VALUE(RetCode,TA_SUCCESS,Success) || ((int)VALUE_HANDLE_DEREF(outNBElement)) == 0 )
357    {
358       VALUE_HANDLE_DEREF_TO_ZERO(outBegIdx);
359       VALUE_HANDLE_DEREF_TO_ZERO(outNBElement);
360       return retCode;
361    }
362 
363    return ENUM_VALUE(RetCode,TA_SUCCESS,Success);
364 }
365 
366 /**** START GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/
367 /* Generated */
368 /* Generated */ #define  USE_SINGLE_PRECISION_INPUT
369 /* Generated */ #if !defined( _MANAGED ) && !defined( _JAVA )
370 /* Generated */    #undef   TA_PREFIX
371 /* Generated */    #define  TA_PREFIX(x) TA_S_##x
372 /* Generated */ #endif
373 /* Generated */ #undef   INPUT_TYPE
374 /* Generated */ #define  INPUT_TYPE float
375 /* Generated */ #if defined( _MANAGED )
376 /* Generated */ enum class Core::RetCode Core::StochRsi( int    startIdx,
377 /* Generated */                                          int    endIdx,
378 /* Generated */                                          cli::array<float>^ inReal,
379 /* Generated */                                          int           optInTimePeriod, /* From 2 to 100000 */
380 /* Generated */                                          int           optInFastK_Period, /* From 1 to 100000 */
381 /* Generated */                                          int           optInFastD_Period, /* From 1 to 100000 */
382 /* Generated */                                          MAType        optInFastD_MAType,
383 /* Generated */                                          [Out]int%    outBegIdx,
384 /* Generated */                                          [Out]int%    outNBElement,
385 /* Generated */                                          cli::array<double>^  outFastK,
386 /* Generated */                                          cli::array<double>^  outFastD )
387 /* Generated */ #elif defined( _JAVA )
388 /* Generated */ public RetCode stochRsi( int    startIdx,
389 /* Generated */                          int    endIdx,
390 /* Generated */                          float        inReal[],
391 /* Generated */                          int           optInTimePeriod, /* From 2 to 100000 */
392 /* Generated */                          int           optInFastK_Period, /* From 1 to 100000 */
393 /* Generated */                          int           optInFastD_Period, /* From 1 to 100000 */
394 /* Generated */                          MAType        optInFastD_MAType,
395 /* Generated */                          MInteger     outBegIdx,
396 /* Generated */                          MInteger     outNBElement,
397 /* Generated */                          double        outFastK[],
398 /* Generated */                          double        outFastD[] )
399 /* Generated */ #else
400 /* Generated */ TA_RetCode TA_S_STOCHRSI( int    startIdx,
401 /* Generated */                           int    endIdx,
402 /* Generated */                           const float  inReal[],
403 /* Generated */                           int           optInTimePeriod, /* From 2 to 100000 */
404 /* Generated */                           int           optInFastK_Period, /* From 1 to 100000 */
405 /* Generated */                           int           optInFastD_Period, /* From 1 to 100000 */
406 /* Generated */                           TA_MAType     optInFastD_MAType,
407 /* Generated */                           int          *outBegIdx,
408 /* Generated */                           int          *outNBElement,
409 /* Generated */                           double        outFastK[],
410 /* Generated */                           double        outFastD[] )
411 /* Generated */ #endif
412 /* Generated */ {
413 /* Generated */    ARRAY_REF(tempRSIBuffer);
414 /* Generated */    ENUM_DECLARATION(RetCode) retCode;
415 /* Generated */    int lookbackTotal, lookbackSTOCHF, tempArraySize;
416 /* Generated */    VALUE_HANDLE_INT(outBegIdx1);
417 /* Generated */    VALUE_HANDLE_INT(outBegIdx2);
418 /* Generated */    VALUE_HANDLE_INT(outNbElement1);
419 /* Generated */  #ifndef TA_FUNC_NO_RANGE_CHECK
420 /* Generated */     if( startIdx < 0 )
421 /* Generated */        return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_START_INDEX,OutOfRangeStartIndex);
422 /* Generated */     if( (endIdx < 0) || (endIdx < startIdx))
423 /* Generated */        return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_END_INDEX,OutOfRangeEndIndex);
424 /* Generated */     #if !defined(_JAVA)
425 /* Generated */     if( !inReal ) return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
426 /* Generated */     #endif
427 /* Generated */     if( (int)optInTimePeriod == TA_INTEGER_DEFAULT )
428 /* Generated */        optInTimePeriod = 14;
429 /* Generated */     else if( ((int)optInTimePeriod < 2) || ((int)optInTimePeriod > 100000) )
430 /* Generated */        return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
431 /* Generated */     if( (int)optInFastK_Period == TA_INTEGER_DEFAULT )
432 /* Generated */        optInFastK_Period = 5;
433 /* Generated */     else if( ((int)optInFastK_Period < 1) || ((int)optInFastK_Period > 100000) )
434 /* Generated */        return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
435 /* Generated */     if( (int)optInFastD_Period == TA_INTEGER_DEFAULT )
436 /* Generated */        optInFastD_Period = 3;
437 /* Generated */     else if( ((int)optInFastD_Period < 1) || ((int)optInFastD_Period > 100000) )
438 /* Generated */        return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
439 /* Generated */     #if !defined(_MANAGED) && !defined(_JAVA)
440 /* Generated */     if( (int)optInFastD_MAType == TA_INTEGER_DEFAULT )
441 /* Generated */        optInFastD_MAType = (TA_MAType)0;
442 /* Generated */     else if( ((int)optInFastD_MAType < 0) || ((int)optInFastD_MAType > 8) )
443 /* Generated */        return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
444 /* Generated */     #endif
445 /* Generated */     #if !defined(_JAVA)
446 /* Generated */     if( !outFastK )
447 /* Generated */        return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
448 /* Generated */     if( !outFastD )
449 /* Generated */        return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
450 /* Generated */     #endif
451 /* Generated */  #endif
452 /* Generated */    VALUE_HANDLE_DEREF_TO_ZERO(outBegIdx);
453 /* Generated */    VALUE_HANDLE_DEREF_TO_ZERO(outNBElement);
454 /* Generated */    lookbackSTOCHF  = LOOKBACK_CALL(STOCHF)( optInFastK_Period, optInFastD_Period, optInFastD_MAType );
455 /* Generated */    lookbackTotal   = LOOKBACK_CALL(RSI)( optInTimePeriod ) + lookbackSTOCHF;
456 /* Generated */    if( startIdx < lookbackTotal )
457 /* Generated */       startIdx = lookbackTotal;
458 /* Generated */    if( startIdx > endIdx )
459 /* Generated */    {
460 /* Generated */       VALUE_HANDLE_DEREF_TO_ZERO(outBegIdx);
461 /* Generated */       VALUE_HANDLE_DEREF_TO_ZERO(outNBElement);
462 /* Generated */       return ENUM_VALUE(RetCode,TA_SUCCESS,Success);
463 /* Generated */    }
464 /* Generated */    VALUE_HANDLE_DEREF(outBegIdx) = startIdx;
465 /* Generated */    tempArraySize = (endIdx - startIdx) + 1 + lookbackSTOCHF;
466 /* Generated */    ARRAY_ALLOC( tempRSIBuffer, tempArraySize );
467 /* Generated */    retCode = FUNCTION_CALL(RSI)(startIdx-lookbackSTOCHF,
468 /* Generated */                                 endIdx,
469 /* Generated */                                 inReal,
470 /* Generated */                                 optInTimePeriod,
471 /* Generated */                                 VALUE_HANDLE_OUT(outBegIdx1),
472 /* Generated */                                 VALUE_HANDLE_OUT(outNbElement1),
473 /* Generated */                                 tempRSIBuffer);
474 /* Generated */    if( retCode != ENUM_VALUE(RetCode,TA_SUCCESS,Success) || VALUE_HANDLE_GET(outNbElement1) == 0 )
475 /* Generated */    {
476 /* Generated */       ARRAY_FREE( tempRSIBuffer );
477 /* Generated */       VALUE_HANDLE_DEREF_TO_ZERO(outBegIdx);
478 /* Generated */       VALUE_HANDLE_DEREF_TO_ZERO(outNBElement);
479 /* Generated */       return retCode;
480 /* Generated */    }
481 /* Generated */    retCode = FUNCTION_CALL_DOUBLE(STOCHF)(0,
482 /* Generated */                                           tempArraySize-1,
483 /* Generated */                                           tempRSIBuffer,
484 /* Generated */                                           tempRSIBuffer,
485 /* Generated */                                           tempRSIBuffer,
486 /* Generated */                                           optInFastK_Period,
487 /* Generated */                                           optInFastD_Period,
488 /* Generated */                                           optInFastD_MAType,
489 /* Generated */                                           VALUE_HANDLE_OUT(outBegIdx2),
490 /* Generated */                                           outNBElement,
491 /* Generated */                                           outFastK,
492 /* Generated */                                           outFastD);
493 /* Generated */    ARRAY_FREE( tempRSIBuffer );
494 /* Generated */    if( retCode != ENUM_VALUE(RetCode,TA_SUCCESS,Success) || ((int)VALUE_HANDLE_DEREF(outNBElement)) == 0 )
495 /* Generated */    {
496 /* Generated */       VALUE_HANDLE_DEREF_TO_ZERO(outBegIdx);
497 /* Generated */       VALUE_HANDLE_DEREF_TO_ZERO(outNBElement);
498 /* Generated */       return retCode;
499 /* Generated */    }
500 /* Generated */    return ENUM_VALUE(RetCode,TA_SUCCESS,Success);
501 /* Generated */ }
502 /* Generated */
503 /* Generated */ #if defined( _MANAGED )
504 /* Generated */ }}} // Close namespace TicTacTec.TA.Lib
505 /* Generated */ #endif
506 /**** END GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/
507 
508