⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ta_sarext.c

📁 股票主要技术指标源码
💻 C
📖 第 1 页 / 共 4 页
字号:
/* TA-LIB Copyright (c) 1999-2007, Mario Fortier * All rights reserved. * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above copyright *   notice, this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright *   notice, this list of conditions and the following disclaimer in *   the documentation and/or other materials provided with the *   distribution. * * - Neither name of author nor the names of its contributors *   may be used to endorse or promote products derived from this *   software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *//* List of contributors: * *  Initial  Name/description *  ------------------------------------------------------------------- *  MF       Mario Fortier *  PP       Peter Pudaite *  CF       Christo Fogelberg * * Change history: * *  MMDDYY BY    Description *  ------------------------------------------------------------------- *  120802 MF    Template creation. *  091503 PP    Reworked TA_SAR to allow customisation of more SAR params. *  092103 MF    Some changes related on first round of tests *  092303 PP    Minor bug fixes. *  122104 MF,CF Fix#1089506 for out-of-bound access to ep_temp. * *//* SAR_ROUNDING is just for test purpose when cross-referencing that * function with example from Wilder's book. Wilder is using two * decimal rounding for simplification. TA-Lib does not round. *//* #define SAR_ROUNDING(x) x=round_pos_2(x) */#define SAR_ROUNDING(x)/**** START GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****//* All code within this section is automatically * generated by gen_code. Any modification will be lost * next time gen_code is run. *//* Generated */ /* Generated */ #if defined( _MANAGED )/* Generated */    #include "TA-Lib-Core.h"/* Generated */    #define TA_INTERNAL_ERROR(Id) (RetCode::InternalError)/* Generated */    namespace TicTacTec { namespace TA { namespace Library {/* Generated */ #elif defined( _JAVA )/* Generated */    #include "ta_defs.h"/* Generated */    #include "ta_java_defs.h"/* Generated */    #define TA_INTERNAL_ERROR(Id) (RetCode.InternalError)/* Generated */ #else/* Generated */    #include <string.h>/* Generated */    #include <math.h>/* Generated */    #include "ta_func.h"/* Generated */ #endif/* Generated */ /* Generated */ #ifndef TA_UTILITY_H/* Generated */    #include "ta_utility.h"/* Generated */ #endif/* Generated */ /* Generated */ #ifndef TA_MEMORY_H/* Generated */    #include "ta_memory.h"/* Generated */ #endif/* Generated */ /* Generated */ #define TA_PREFIX(x) TA_##x/* Generated */ #define INPUT_TYPE   double/* Generated */ /* Generated */ #if defined( _MANAGED )/* Generated */ int Core::SarExtLookback( double        optInStartValue, /* From TA_REAL_MIN to TA_REAL_MAX *//* Generated */                         double        optInOffsetOnReverse, /* From 0 to TA_REAL_MAX *//* Generated */                         double        optInAccelerationInitLong, /* From 0 to TA_REAL_MAX *//* Generated */                         double        optInAccelerationLong, /* From 0 to TA_REAL_MAX *//* Generated */                         double        optInAccelerationMaxLong, /* From 0 to TA_REAL_MAX *//* Generated */                         double        optInAccelerationInitShort, /* From 0 to TA_REAL_MAX *//* Generated */                         double        optInAccelerationShort, /* From 0 to TA_REAL_MAX *//* Generated */                         double        optInAccelerationMaxShort )  /* From 0 to TA_REAL_MAX *//* Generated */ /* Generated */ #elif defined( _JAVA )/* Generated */ public int sarExtLookback( double        optInStartValue, /* From TA_REAL_MIN to TA_REAL_MAX *//* Generated */                          double        optInOffsetOnReverse, /* From 0 to TA_REAL_MAX *//* Generated */                          double        optInAccelerationInitLong, /* From 0 to TA_REAL_MAX *//* Generated */                          double        optInAccelerationLong, /* From 0 to TA_REAL_MAX *//* Generated */                          double        optInAccelerationMaxLong, /* From 0 to TA_REAL_MAX *//* Generated */                          double        optInAccelerationInitShort, /* From 0 to TA_REAL_MAX *//* Generated */                          double        optInAccelerationShort, /* From 0 to TA_REAL_MAX *//* Generated */                          double        optInAccelerationMaxShort )  /* From 0 to TA_REAL_MAX *//* Generated */ /* Generated */ #else/* Generated */ int TA_SAREXT_Lookback( double        optInStartValue, /* From TA_REAL_MIN to TA_REAL_MAX *//* Generated */                       double        optInOffsetOnReverse, /* From 0 to TA_REAL_MAX *//* Generated */                       double        optInAccelerationInitLong, /* From 0 to TA_REAL_MAX *//* Generated */                       double        optInAccelerationLong, /* From 0 to TA_REAL_MAX *//* Generated */                       double        optInAccelerationMaxLong, /* From 0 to TA_REAL_MAX *//* Generated */                       double        optInAccelerationInitShort, /* From 0 to TA_REAL_MAX *//* Generated */                       double        optInAccelerationShort, /* From 0 to TA_REAL_MAX *//* Generated */                       double        optInAccelerationMaxShort )  /* From 0 to TA_REAL_MAX *//* Generated */ /* Generated */ #endif/**** END GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/{   /* insert local variable here *//**** START GENCODE SECTION 2 - DO NOT DELETE THIS LINE ****//* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK/* Generated */    if( optInStartValue == TA_REAL_DEFAULT )/* Generated */       optInStartValue = 0.000000e+0;/* Generated */    else if( (optInStartValue < -3.000000e+37) ||/* Generated */  (optInStartValue > 3.000000e+37) )/* Generated */       return -1;/* Generated */ /* Generated */    if( optInOffsetOnReverse == TA_REAL_DEFAULT )/* Generated */       optInOffsetOnReverse = 0.000000e+0;/* Generated */    else if( (optInOffsetOnReverse < 0.000000e+0) ||/* Generated */  (optInOffsetOnReverse > 3.000000e+37) )/* Generated */       return -1;/* Generated */ /* Generated */    if( optInAccelerationInitLong == TA_REAL_DEFAULT )/* Generated */       optInAccelerationInitLong = 2.000000e-2;/* Generated */    else if( (optInAccelerationInitLong < 0.000000e+0) ||/* Generated */  (optInAccelerationInitLong > 3.000000e+37) )/* Generated */       return -1;/* Generated */ /* Generated */    if( optInAccelerationLong == TA_REAL_DEFAULT )/* Generated */       optInAccelerationLong = 2.000000e-2;/* Generated */    else if( (optInAccelerationLong < 0.000000e+0) ||/* Generated */  (optInAccelerationLong > 3.000000e+37) )/* Generated */       return -1;/* Generated */ /* Generated */    if( optInAccelerationMaxLong == TA_REAL_DEFAULT )/* Generated */       optInAccelerationMaxLong = 2.000000e-1;/* Generated */    else if( (optInAccelerationMaxLong < 0.000000e+0) ||/* Generated */  (optInAccelerationMaxLong > 3.000000e+37) )/* Generated */       return -1;/* Generated */ /* Generated */    if( optInAccelerationInitShort == TA_REAL_DEFAULT )/* Generated */       optInAccelerationInitShort = 2.000000e-2;/* Generated */    else if( (optInAccelerationInitShort < 0.000000e+0) ||/* Generated */  (optInAccelerationInitShort > 3.000000e+37) )/* Generated */       return -1;/* Generated */ /* Generated */    if( optInAccelerationShort == TA_REAL_DEFAULT )/* Generated */       optInAccelerationShort = 2.000000e-2;/* Generated */    else if( (optInAccelerationShort < 0.000000e+0) ||/* Generated */  (optInAccelerationShort > 3.000000e+37) )/* Generated */       return -1;/* Generated */ /* Generated */    if( optInAccelerationMaxShort == TA_REAL_DEFAULT )/* Generated */       optInAccelerationMaxShort = 2.000000e-1;/* Generated */    else if( (optInAccelerationMaxShort < 0.000000e+0) ||/* Generated */  (optInAccelerationMaxShort > 3.000000e+37) )/* Generated */       return -1;/* Generated */ /* Generated */ #endif /* TA_FUNC_NO_RANGE_CHECK *//**** END GENCODE SECTION 2 - DO NOT DELETE THIS LINE ****/   /* insert lookback code here. */   UNUSED_VARIABLE(optInStartValue);   UNUSED_VARIABLE(optInOffsetOnReverse);   UNUSED_VARIABLE(optInAccelerationInitLong);   UNUSED_VARIABLE(optInAccelerationLong);   UNUSED_VARIABLE(optInAccelerationMaxLong);   UNUSED_VARIABLE(optInAccelerationInitShort);   UNUSED_VARIABLE(optInAccelerationShort);   UNUSED_VARIABLE(optInAccelerationMaxShort);   /* SAR always sacrifices one price bar to establish the    * initial extreme price.    */   return 1;}/**** START GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****//* * TA_SAREXT - Parabolic SAR - Extended *  * Input  = High, Low * Output = double *  * Optional Parameters * ------------------- * optInStartValue:(From TA_REAL_MIN to TA_REAL_MAX) *    Start value and direction. 0 for Auto, >0 for Long, <0 for Short *  * optInOffsetOnReverse:(From 0 to TA_REAL_MAX) *    Percent offset added/removed to initial stop on short/long reversal *  * optInAccelerationInitLong:(From 0 to TA_REAL_MAX) *    Acceleration Factor initial value for the Long direction *  * optInAccelerationLong:(From 0 to TA_REAL_MAX) *    Acceleration Factor for the Long direction *  * optInAccelerationMaxLong:(From 0 to TA_REAL_MAX) *    Acceleration Factor maximum value for the Long direction *  * optInAccelerationInitShort:(From 0 to TA_REAL_MAX) *    Acceleration Factor initial value for the Short direction *  * optInAccelerationShort:(From 0 to TA_REAL_MAX) *    Acceleration Factor for the Short direction *  * optInAccelerationMaxShort:(From 0 to TA_REAL_MAX) *    Acceleration Factor maximum value for the Short direction *  *  *//* Generated */ /* Generated */ #if defined( _MANAGED ) && defined( USE_SUBARRAY )/* Generated */ enum class Core::RetCode Core::SarExt( int    startIdx,/* Generated */                                        int    endIdx,/* Generated */                                        SubArray^    inHigh,/* Generated */                                        SubArray^    inLow,/* Generated */                                        double        optInStartValue, /* From TA_REAL_MIN to TA_REAL_MAX *//* Generated */                                        double        optInOffsetOnReverse, /* From 0 to TA_REAL_MAX *//* Generated */                                        double        optInAccelerationInitLong, /* From 0 to TA_REAL_MAX *//* Generated */                                        double        optInAccelerationLong, /* From 0 to TA_REAL_MAX *//* Generated */                                        double        optInAccelerationMaxLong, /* From 0 to TA_REAL_MAX *//* Generated */                                        double        optInAccelerationInitShort, /* From 0 to TA_REAL_MAX *//* Generated */                                        double        optInAccelerationShort, /* From 0 to TA_REAL_MAX *//* Generated */                                        double        optInAccelerationMaxShort, /* From 0 to TA_REAL_MAX *//* Generated */                                        [Out]int%    outBegIdx,/* Generated */                                        [Out]int%    outNBElement,/* Generated */                                        cli::array<double>^  outReal )/* Generated */ #elif defined( _MANAGED )/* Generated */ enum class Core::RetCode Core::SarExt( int    startIdx,/* Generated */                                        int    endIdx,/* Generated */                                        cli::array<double>^ inHigh,/* Generated */                                        cli::array<double>^ inLow,/* Generated */                                        double        optInStartValue, /* From TA_REAL_MIN to TA_REAL_MAX */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -