Example #1
0
/**** Local functions definitions.     ****/
static TA_RetCode rangeTestFunction( TA_Libc *libHandle, 
                              TA_Integer startIdx,
                              TA_Integer endIdx,
                              TA_Real *outputBuffer,
                              TA_Integer *outBegIdx,
                              TA_Integer *outNbElement,
                              TA_Integer *lookback,
                              void *opaqueData,
                              unsigned int outputNb )
{
   TA_RetCode retCode;
   TA_RangeTestParam *testParam;

   (void)outputNb;
  
   testParam = (TA_RangeTestParam *)opaqueData;   

   if( testParam->test->theFunction == TA_MOM_TEST )
   {
      retCode = TA_MOM( libHandle,
                        startIdx,
                        endIdx,
                        testParam->close,
                        testParam->test->optInTimePeriod_0,                        
                        outBegIdx,
                        outNbElement,
                        outputBuffer );

      *lookback = TA_MOM_Lookback(testParam->test->optInTimePeriod_0 );
   }
   else if( testParam->test->theFunction == TA_ROC_TEST )
   {
      retCode = TA_ROC( libHandle,
                        startIdx,
                        endIdx,
                        testParam->close,
                        testParam->test->optInTimePeriod_0,                        
                        outBegIdx,
                        outNbElement,
                        outputBuffer );
      *lookback = TA_ROC_Lookback(testParam->test->optInTimePeriod_0 );
   }
   else if( testParam->test->theFunction == TA_ROCR_TEST )
   {
      retCode = TA_ROCR( libHandle,
                         startIdx,
                         endIdx,
                         testParam->close,
                         testParam->test->optInTimePeriod_0,                         
                         outBegIdx,
                         outNbElement,
                         outputBuffer );
      *lookback = TA_ROCR_Lookback(testParam->test->optInTimePeriod_0 );
   }
   else
      retCode = TA_UNKNOWN_ERR;

   return retCode;
}
Example #2
0
/**** Local functions definitions.     ****/
static TA_RetCode rangeTestFunction( TA_Integer    startIdx,
                                     TA_Integer    endIdx,
                                     TA_Real      *outputBuffer,
                                     TA_Integer   *outputBufferInt,
                                     TA_Integer   *outBegIdx,
                                     TA_Integer   *outNbElement,
                                     TA_Integer   *lookback,
                                     void         *opaqueData,
                                     unsigned int  outputNb,
                                     unsigned int *isOutputInteger )
{
   TA_RetCode retCode;
   TA_RangeTestParam *testParam;

   (void)outputNb;
   (void)outputBufferInt;
  
   *isOutputInteger = 0;

   testParam = (TA_RangeTestParam *)opaqueData;   
   switch( testParam->test->theFunction )
   {
   case TA_MOM_TEST:
      retCode = TA_MOM(
                        startIdx,
                        endIdx,
                        testParam->close,
                        testParam->test->optInTimePeriod,                        
                        outBegIdx,
                        outNbElement,
                        outputBuffer );

      *lookback = TA_MOM_Lookback(testParam->test->optInTimePeriod );
      break;
   case TA_ROC_TEST:
      retCode = TA_ROC(
                        startIdx,
                        endIdx,
                        testParam->close,
                        testParam->test->optInTimePeriod,                        
                        outBegIdx,
                        outNbElement,
                        outputBuffer );
      *lookback = TA_ROC_Lookback(testParam->test->optInTimePeriod );
      break;
   case TA_ROCR_TEST:
      retCode = TA_ROCR(
                         startIdx,
                         endIdx,
                         testParam->close,
                         testParam->test->optInTimePeriod,                         
                         outBegIdx,
                         outNbElement,
                         outputBuffer );
      *lookback = TA_ROCR_Lookback(testParam->test->optInTimePeriod );
      break;
   case TA_ROCR100_TEST:
      retCode = TA_ROCR100(
                            startIdx,
                            endIdx,
                            testParam->close,
                            testParam->test->optInTimePeriod,                         
                            outBegIdx,
                            outNbElement,
                            outputBuffer );
      *lookback = TA_ROCR100_Lookback(testParam->test->optInTimePeriod );
      break;
   case TA_ROCP_TEST:
      retCode = TA_ROCP(
                         startIdx,
                         endIdx,
                         testParam->close,
                         testParam->test->optInTimePeriod,                         
                         outBegIdx,
                         outNbElement,
                         outputBuffer );
      *lookback = TA_ROCP_Lookback(testParam->test->optInTimePeriod );
      break;
   default:
      retCode = TA_INTERNAL_ERROR(130);
   }

   return retCode;
}