Example #1
0
static VALUE ta_func_setup_in_price(VALUE self, VALUE param_index, VALUE in_open, VALUE in_high, VALUE in_low, VALUE in_close, VALUE in_volume, VALUE in_oi)
{
  TA_RetCode ret_code;
  ParamHolder *param_holder;
  Data_Get_Struct(self, ParamHolder, param_holder);
  double **dp = param_holder->in;

  ret_code = TA_SetInputParamPricePtr(param_holder->p,
                                      FIX2INT(param_index),
                                      FLT2DBL(&dp[0], in_open),
                                      FLT2DBL(&dp[1], in_high),
                                      FLT2DBL(&dp[2], in_low),
                                      FLT2DBL(&dp[3], in_close),
                                      FLT2DBL(&dp[4], in_volume),
                                      FLT2DBL(&dp[5], in_oi));
  if ( ret_code != TA_SUCCESS )
    rb_raise(rb_eRuntimeError, "unsuccess return code TA_SetInputParamPricePtr");
}
Example #2
0
/* Abstract call for all candlestick functions.
 *
 * Call the function by 'name'.
 * 
 * Optional inputs are pass as an array of double.
 * Elements will be converted to integer as needed.
 *
 * All outputs are returned in the remaining parameters.
 *
 * 'lookback' is the return value of the corresponding Lookback function.
 * taFuncRetCode is the return code from the call of the TA function.
 *
 */
static ErrorNumber callCandlestick( TA_ParamHolder **paramHolderPtr,
                                    const char   *name,
                                    int           startIdx,
                                    int           endIdx,
                                    const double *inOpen,
                                    const double *inHigh,
                                    const double *inLow,
                                    const double *inClose,
                                    const double  optInArray[],
                                    int          *outBegIdx,
                                    int          *outNbElement,                                    
                                    int           outInteger[],
                                    int          *lookback,
                                    TA_RetCode   *taFuncRetCode )
{

   /* Use the abstract interface to call the function by name. */
   TA_ParamHolder *paramHolder;
   const TA_FuncHandle *handle;
   const TA_FuncInfo *funcInfo;
   const TA_InputParameterInfo *inputInfo;
   const TA_OutputParameterInfo *outputInfo;

   TA_RetCode retCode;

   (void)optInArray;
   
   /* Speed optimization if paramHolder is already initialized. */   
   paramHolder = *paramHolderPtr;
   if( !paramHolder )
   {
      retCode = TA_GetFuncHandle( name, &handle );
      if( retCode != TA_SUCCESS )
      {
         printf( "Can't get the function handle [%d]\n", retCode );
         return TA_TSTCDL_GETFUNCHANDLE_FAIL;   
      }
                             
      retCode = TA_ParamHolderAlloc( handle, &paramHolder );
      if( retCode != TA_SUCCESS )
      {
         printf( "Can't allocate the param holder [%d]\n", retCode );
         return TA_TSTCDL_PARAMHOLDERALLOC_FAIL;
      }

      *paramHolderPtr = paramHolder;
      TA_GetFuncInfo( handle, &funcInfo );

      /* Verify that the input are only OHLC. */
      if( funcInfo->nbInput != 1 )
      {
         printf( "Candlestick are expected to use only OHLC as input.\n" );
         return TA_TSTCDL_NBINPUT_WRONG;
      }

      TA_GetInputParameterInfo( handle, 0, &inputInfo );

      if( inputInfo->type != TA_Input_Price )
      {
         printf( "Candlestick are expected to use only OHLC as input.\n" );
         return TA_TSTCDL_INPUT_TYPE_WRONG;
      }
   
      if( inputInfo->flags != (TA_IN_PRICE_OPEN |
                               TA_IN_PRICE_HIGH |
                               TA_IN_PRICE_LOW  |
                               TA_IN_PRICE_CLOSE) )
      {
         printf( "Candlestick are expected to use only OHLC as input.\n" );
         return TA_TSTCDL_INPUT_FLAG_WRONG;
      }
    
      /* Set the optional inputs. */
   
      /* Verify that there is only one output. */
      if( funcInfo->nbOutput != 1 )
      {
         printf( "Candlestick are expected to have only one output array.\n" );
         return TA_TSTCDL_NBOUTPUT_WRONG;
      }

      TA_GetOutputParameterInfo( handle, 0, &outputInfo );
      if( outputInfo->type != TA_Output_Integer )
      {
         printf( "Candlestick are expected to have only one output array of type integer.\n" );
         return TA_TSTCDL_OUTPUT_TYPE_WRONG;
      }

      /* !!!!!!!!!!!!! TO BE DONE !!!!!!!!!!!!!!!!!! 
       * For now all candlestick functions will be called with default optional parameter.
       */
   }

   /* Set the input buffers. */
   TA_SetInputParamPricePtr( paramHolder, 0,
                             inOpen, inHigh, inLow, inClose, NULL, NULL );

   TA_SetOutputParamIntegerPtr(paramHolder,0,outInteger);


   /* Do the function call. */
   *taFuncRetCode = TA_CallFunc(paramHolder,startIdx,endIdx,outBegIdx,outNbElement);

   if( *taFuncRetCode != TA_SUCCESS )
   {
      printf( "TA_CallFunc() failed [%d]\n", *taFuncRetCode );
      TA_ParamHolderFree( paramHolder );
      return TA_TSTCDL_CALLFUNC_FAIL;
   }      

   /* Do the lookback function call. */
   retCode = TA_GetLookback( paramHolder, lookback );
   if( retCode != TA_SUCCESS )
   {
      printf( "TA_GetLookback() failed [%d]\n", retCode );
      TA_ParamHolderFree( paramHolder );
      return TA_TSTCDL_GETLOOKBACK_FAIL;
   }

   return TA_TEST_PASS;   
}
Example #3
0
PlotLine * TALIB::calculateCustom (QString &p, QPtrList<PlotLine> &d)
{
  // format: METHOD, ..., ...., ..... etc (first parm must be the method)

  QStringList l = QStringList::split(",", p, FALSE);

  if (! l.count())
  {
    qDebug("TALIB::calculateCustom: no method parm");
    return 0;
  }
  
  TA_Integer start = 0;
  TA_Integer end = data->count() - 1;
  if (d.count())
    end = d.at(0)->getSize() - 1;
  TA_Integer outstart;
  TA_Integer count;
  PlotLine *line = new PlotLine;
  // sometimes are not enough data available
  // to calc anything
  if(end < 0) 
    return line;
  
  // open a TALIB handle
  const TA_FuncHandle *handle;
  TA_RetCode retCode = TA_GetFuncHandle(l[0], &handle);
  if (retCode != TA_SUCCESS)
  {
    qDebug("TALIB::calculateCustom:can't open handle");
    return 0;
  }

  // get info on the function
  const TA_FuncInfo *theInfo;
  retCode = TA_GetFuncInfo(handle, &theInfo);
  if (retCode != TA_SUCCESS)
  {
    qDebug("TALIB::calculateCustom:can't get function info");
    return 0;
  }

  // create parm holder
  TA_ParamHolder *parmHolder;
  retCode = TA_ParamHolderAlloc(handle, &parmHolder);
  if (retCode != TA_SUCCESS)
  {
    qDebug("TALIB::calculateCustom:can't create parm holder");
    return 0;
  }

  // create and input arrays
  int loop = data->count();
  TA_Real open[loop];
  TA_Real high[loop];
  TA_Real low[loop];
  TA_Real close[loop];
  TA_Real volume[loop];
  TA_Real oi[loop];
  TA_Real treal[loop];

  int sparmIndex = 1;

  // setup the input arrays
  const TA_InputParameterInfo *inputParms;
  for (loop = 0; loop < (int) theInfo->nbInput; loop++ )
  {
    TA_GetInputParameterInfo(theInfo->handle, loop, &inputParms);

    if (inputParms->type == TA_Input_Price)
    {
      // populate the input arrays
      int loop2;
      for (loop2 = 0; loop2 < data->count(); loop2++)
      {
        open[loop2] = (TA_Real) data->getOpen(loop2);
        high[loop2] = (TA_Real) data->getHigh(loop2);
        low[loop2] = (TA_Real) data->getLow(loop2);
        close[loop2] = (TA_Real) data->getClose(loop2);
        volume[loop2] = (TA_Real) data->getVolume(loop2);
        oi[loop2] = (TA_Real) data->getOI(loop2);
      }

      retCode = TA_SetInputParamPricePtr(parmHolder, loop, &open[0], &high[0], &low[0], &close[0],
                                         &volume[0], &oi[0]);
      if (retCode != TA_SUCCESS)
      {
        qDebug("TALIB::calculateCustom:cannot set input prices");
        return 0;
      }
    }

    if (inputParms->type == TA_Input_Real)
    {
      if (! d.count())
      {
        qDebug("TALIB::calculateCustom: no input");
        return 0;
      }

      if (sparmIndex >= (int) l.count())
      {
        qDebug("TALIB::calculateCustom: input invalid number of parms");
        return 0;
      }

      PlotLine *line =  d.at(0);
      int loop2;
      for (loop2 = 0; loop2 < line->getSize(); loop2++)
        treal[loop2] = (TA_Real) line->getData(loop2);

      retCode = TA_SetInputParamRealPtr(parmHolder, loop, &treal[0]);
      if (retCode != TA_SUCCESS)
      {
        qDebug("TALIB::calculateCustom:cannot set real price");
        return 0;
      }

      sparmIndex++;
    }
  }

  if (sparmIndex < (int) l.count())
  {
    QStringList mal;
    getMATypes(mal);
    mal.remove("Wilder");
    int t = 0;

    // setup the optinput parms
    const TA_OptInputParameterInfo *optInfo;
    for (loop = 0; loop < (int) theInfo->nbOptInput; loop++ )
    {
      TA_GetOptInputParameterInfo(theInfo->handle, loop, &optInfo);
      switch (optInfo->type)
      {
        case TA_OptInput_RealRange:
          if (sparmIndex >= (int) l.count())
          {
            qDebug("TALIB::calculateCustom: optinput real invalid number of parms");
            return 0;
          }

          retCode = TA_SetOptInputParamReal(parmHolder, loop, (TA_Real) l[sparmIndex].toDouble());
          if (retCode != TA_SUCCESS)
          {
            qDebug("TALIB::calculateCustom:cannot set inputopt real");
            return 0;
          }
          sparmIndex++;
          break;
        case TA_OptInput_IntegerRange:
          if (sparmIndex >= (int) l.count())
          {
            qDebug("TALIB::calculateCustom: optinput integer invalid number of parms");
            return 0;
          }

          retCode = TA_SetOptInputParamInteger(parmHolder, loop, (TA_Integer) l[sparmIndex].toInt());
          if (retCode != TA_SUCCESS)
          {
            qDebug("TALIB::calculateCustom:cannot set inputopt integer");
            return 0;
          }
          sparmIndex++;
          break;

        case TA_OptInput_IntegerList:
          if (sparmIndex >= (int) l.count())
          {
            qDebug("TALIB::calculateCustom: optinput integerList invalid number of parms");
            return 0;
          }
    
          t = mal.findIndex(l[sparmIndex]);
          if (t == -1)
            t = 0;
          retCode = TA_SetOptInputParamInteger(parmHolder, loop, (TA_Integer) t);
          if (retCode != TA_SUCCESS)
          {
            qDebug("TALIB::calculateCustom:cannot set inputopt integer");
            return 0;
          }
          sparmIndex++;
          break;
        default:
          break;
      }
    }
  }

  // setup the output arrays
  TA_Real out1[data->count()];
  TA_Real out2[data->count()];
  TA_Real out3[data->count()];
  TA_Integer out4[data->count()];
  const TA_OutputParameterInfo *outInfo;
  for (loop = 0; loop < (int) theInfo->nbOutput; loop++)
  {
    retCode = TA_GetOutputParameterInfo(handle, loop, &outInfo);
    if (retCode != TA_SUCCESS)
    {
      qDebug("TALIB::calculateCustom:cannot get output info");
      return 0;
    }

    switch (loop)
    {
      case 0:
        if (outInfo->type == TA_Output_Integer)
        {
          retCode = TA_SetOutputParamIntegerPtr(parmHolder, loop, &out4[0]);
          if (retCode != TA_SUCCESS)
          {
            qDebug("TALIB::calculateCustom:cannot set output4");
            return 0;
          }
        }
        else
        {
          retCode = TA_SetOutputParamRealPtr(parmHolder, loop, &out1[0]);
          if (retCode != TA_SUCCESS)
          {
            qDebug("TALIB::calculateCustom:cannot set output1");
            return 0;
          }
        }
        break;      
      case 1:
        retCode = TA_SetOutputParamRealPtr(parmHolder, loop, &out2[0]);
        if (retCode != TA_SUCCESS)
        {
          qDebug("TALIB::calculateCustom:cannot set output2");
          return 0;
        }
        break;      
      case 2:
        retCode = TA_SetOutputParamRealPtr(parmHolder, loop, &out3[0]);
        if (retCode != TA_SUCCESS)
        {
          qDebug("TALIB::calculateCustom:cannot set output3");
          return 0;
        }
        break;
      default:
        break;
    }
  }

  // call the function
  /*
  TA_Integer start = 0;
  TA_Integer end = data->count() - 1;
  if (d.count())
    end = d.at(0)->getSize() - 1;
  TA_Integer outstart;
  TA_Integer count;
  PlotLine *line = new PlotLine;
  */
  retCode = TA_CallFunc(parmHolder, start, end, &outstart, &count);
  if (retCode != TA_SUCCESS)
  {
    printError(QString("TALIB::calculateCustom:TA_CallFunc"), retCode);
    qDebug("p=%s  start=%d  end=%d",p.ascii(), start, end);
  }
  else
  {
    // create the plotlines
    int loop2;
    retCode = TA_GetOutputParameterInfo(handle, 0, &outInfo);
    if (retCode != TA_SUCCESS)
    {
      qDebug("TALIB::calculateCustom:cannot get output info");
      return 0;
    }
    
    if (outInfo->type == TA_Output_Integer)
    {
      for (loop2 = 0; loop2 < count; loop2++)
        line->append((double) out4[loop2]);
    }
    else
    {
      if (theInfo->nbOutput > 1)
      {
        bool ok;
        l[l.count() - 1].toInt(&ok);
        if (! ok)
        {
          qDebug("TALIB::calculateCustom: parm #%i invalid, not an INTEGER", loop + 1);
          return 0;
        }

        switch (l[l.count() - 1].toInt(&ok))
        {
          case 2:
            for (loop2 = 0; loop2 < count; loop2++)
              line->append((double) out2[loop2]);
            break;
          case 3:
            for (loop2 = 0; loop2 < count; loop2++)
              line->append((double) out3[loop2]);
            break;
          default:
            for (loop2 = 0; loop2 < count; loop2++)
              line->append((double) out1[loop2]);
            break;
        }
      }
      else
      {
        for (loop2 = 0; loop2 < count; loop2++)
          line->append((double) out1[loop2]);
      }
    }
  }

  retCode = TA_ParamHolderFree(parmHolder);
  if (retCode != TA_SUCCESS)
    qDebug("TALIB::calculateCustom:can't delete parm holder");

  return line;
}
Example #4
0
Indicator * TALIB::calculate ()
{
  Indicator *output = new Indicator;
  output->setDateFlag(dateFlag);
  output->setLogScale(logScale);

  // open a TALIB handle
  const TA_FuncHandle *handle;
  QString ts = "method";
  QString ts2;
  parms.getData(ts, ts2);
  TA_RetCode retCode = TA_GetFuncHandle(ts2, &handle);
  if (retCode != TA_SUCCESS)
  {
    qDebug("TALIB::calculate:can't open handle");
    return output;
  }

  // get info on the function
  const TA_FuncInfo *theInfo;
  retCode = TA_GetFuncInfo(handle, &theInfo);
  if (retCode != TA_SUCCESS)
  {
    qDebug("TALIB::calculate:can't get function info");
    return output;
  }

  // create parm holder
  TA_ParamHolder *parmHolder;
  retCode = TA_ParamHolderAlloc(handle, &parmHolder);
  if (retCode != TA_SUCCESS)
  {
    qDebug("TALIB::calculate:can't create parm holder");
    return output;
  }

  // create and populate the input arrays
  int loop = data->count();
  TA_Real open[loop];
  TA_Real high[loop];
  TA_Real low[loop];
  TA_Real close[loop];
  TA_Real volume[loop];
  TA_Real oi[loop];
  for (loop = 0; loop < data->count(); loop++)
  {
    open[loop] = (TA_Real) data->getOpen(loop);
    high[loop] = (TA_Real) data->getHigh(loop);
    low[loop] = (TA_Real) data->getLow(loop);
    close[loop] = (TA_Real) data->getClose(loop);
    volume[loop] = (TA_Real) data->getVolume(loop);
    oi[loop] = (TA_Real) data->getOI(loop);
  }

  // setup the input arrays
  const TA_InputParameterInfo *inputParms;
  for (loop = 0; loop < (int) theInfo->nbInput; loop++ )
  {
    TA_GetInputParameterInfo(theInfo->handle, loop, &inputParms);
    QString s;
    int tint = 3;
    switch (inputParms->type)
    {
      case TA_Input_Price:
        retCode = TA_SetInputParamPricePtr(parmHolder, loop, &open[0], &high[0], &low[0],
                                           &close[0], &volume[0], &oi[0]);
        if (retCode != TA_SUCCESS)
          qDebug("TALIB::calculate:cannot set input prices");
        break;
      case TA_Input_Real:
        s = QObject::tr("input") + QString::number(loop + 1);
        tint = parms.getInt(s);
        switch (tint)
        {
          case 0:
            retCode = TA_SetInputParamRealPtr(parmHolder, loop, &open[0]);
            if (retCode != TA_SUCCESS)
              qDebug("TALIB::calculate:cannot set real price");
            break;
          case 1:
            retCode = TA_SetInputParamRealPtr(parmHolder, loop, &high[0]);
            if (retCode != TA_SUCCESS)
              qDebug("TALIB::calculate:cannot set real price");
            break;
          case 2:
            retCode = TA_SetInputParamRealPtr(parmHolder, loop, &low[0]);
            if (retCode != TA_SUCCESS)
              qDebug("TALIB::calculate:cannot set real price");
            break;
          case 3:
            retCode = TA_SetInputParamRealPtr(parmHolder, loop, &close[0]);
            if (retCode != TA_SUCCESS)
              qDebug("TALIB::calculate:cannot set real price");
            break;
          case 4:
            retCode = TA_SetInputParamRealPtr(parmHolder, loop, &volume[0]);
            if (retCode != TA_SUCCESS)
              qDebug("TALIB::calculate:cannot set integer price");
            break;
          case 5:
            retCode = TA_SetInputParamRealPtr(parmHolder, loop, &oi[0]);
            if (retCode != TA_SUCCESS)
              qDebug("TALIB::calculate:cannot set integer price");
            break;
          default:
            break;
        }
        break;
      case TA_Input_Integer:
        break;
      default:
        break;
    }
  }

  // setup the optinput parms
  const TA_OptInputParameterInfo *optInfo;
  for (loop = 0; loop < (int) theInfo->nbOptInput; loop++ )
  {
    TA_GetOptInputParameterInfo(theInfo->handle, loop, &optInfo);
    QString s = optInfo->displayName;
    switch (optInfo->type)
    {
      case TA_OptInput_RealRange:
        retCode = TA_SetOptInputParamReal(parmHolder, loop, (TA_Real) parms.getDouble(s));
        if (retCode != TA_SUCCESS)
          qDebug("TALIB::calculate:cannot set inputopt real");
        break;
      case TA_OptInput_IntegerRange:
        retCode = TA_SetOptInputParamInteger(parmHolder, loop, (TA_Integer) parms.getInt(s));
        if (retCode != TA_SUCCESS)
          qDebug("TALIB::calculate:cannot set inputopt integer");
        break;
      case TA_OptInput_IntegerList:
        retCode = TA_SetOptInputParamInteger(parmHolder, loop, (TA_Integer) parms.getInt(s));
        if (retCode != TA_SUCCESS)
          qDebug("TALIB::calculate:cannot set inputopt integerlist");
        break;
      default:
        break;
    }
  }

  // setup the output arrays
  TA_Real out1[data->count()];
  TA_Real out2[data->count()];
  TA_Real out3[data->count()];
  TA_Integer out4[data->count()];
  const TA_OutputParameterInfo *outInfo;
  for (loop = 0; loop < (int) theInfo->nbOutput; loop++)
  {
    retCode = TA_GetOutputParameterInfo(handle, loop, &outInfo);
    if (retCode != TA_SUCCESS)
    {
      qDebug("TALIB::calculate:cannot get output info");
      continue;
    }

    switch (loop)
    {
      case 0:
        if (outInfo->type == TA_Output_Integer)
        {
          retCode = TA_SetOutputParamIntegerPtr(parmHolder, loop, &out4[0]);
          if (retCode != TA_SUCCESS)
            qDebug("TALIB::calculate:cannot set output4");
        }
        else
        {
          retCode = TA_SetOutputParamRealPtr(parmHolder, loop, &out1[0]);
          if (retCode != TA_SUCCESS)
            qDebug("TALIB::calculate:cannot set output1");
        }
        break;      
      case 1:
        retCode = TA_SetOutputParamRealPtr(parmHolder, loop, &out2[0]);
        if (retCode != TA_SUCCESS)
          qDebug("TALIB::calculate:cannot set output2");
        break;      
      case 2:
        retCode = TA_SetOutputParamRealPtr(parmHolder, loop, &out3[0]);
        if (retCode != TA_SUCCESS)
          qDebug("TALIB::calculate:cannot set output3");
        break;
      default:
        break;
    }
  }

  // call the function
  TA_Integer start = 0;
  TA_Integer end = data->count() - 1;
  TA_Integer outstart;
  TA_Integer count;
  retCode = TA_CallFunc(parmHolder, start, end, &outstart, &count);
  if (retCode != TA_SUCCESS)
    qDebug("TALIB::calculate:call function failed");
  else
  {
    // create the plotlines
    const TA_OutputParameterInfo *outInfo;
    for (loop = 0; loop < (int) theInfo->nbOutput; loop++ )
    {
      TA_GetOutputParameterInfo(theInfo->handle, loop, &outInfo);
      QString base = outInfo->paramName;
      base = base.right(base.length() - 3);
      if (! base.left(4).compare("Real"))
        base = base.right(base.length() - 4);
      if (! base.left(7).compare("Integer"))
        base = base.right(base.length() - 7);
      if (! base.length())
        base = QObject::tr("Plot");

      PlotLine *line = new PlotLine;

      QString s = base + " " + QObject::tr("Color");
      parms.getData(s, ts);
      QColor color(ts);
      line->setColor(color);

      s = base + " " + QObject::tr("Label");
      parms.getData(s, ts);
      line->setLabel(ts);

      s = base + " " + QObject::tr("Line Type");
      line->setType((PlotLine::LineType)parms.getInt(s));

      retCode = TA_GetOutputParameterInfo(handle, loop, &outInfo);
      if (retCode != TA_SUCCESS)
      {
        qDebug("TALIB::calculate:cannot get output info");
        delete line;
        continue;
      }

      int loop2;
      switch (loop)
      {
        case 0:
          if (outInfo->type == TA_Output_Integer)
          {
            for (loop2 = 0; loop2 < count; loop2++)
              line->append((double) out4[loop2]);
          }
          else
          {
            for (loop2 = 0; loop2 < count; loop2++)
              line->append((double) out1[loop2]);
          }
          break;      
        case 1:
          for (loop2 = 0; loop2 < count; loop2++)
            line->append((double) out2[loop2]);
          break;      
        case 2:
          for (loop2 = 0; loop2 < count; loop2++)
            line->append((double) out3[loop2]);
          break;
        default:
          break;
      }

      if (line->getType() == PlotLine::Histogram || line->getType() == PlotLine::HistogramBar)
        output->prependLine(line);
      else
        output->addLine(line);
    }
  }

  retCode = TA_ParamHolderFree(parmHolder);
  if (retCode != TA_SUCCESS)
    qDebug("TALIB::calculate:can't delete parm holder");

  return output;
}
Example #5
0
static ErrorNumber callWithDefaults( const char *funcName, const double *input, const int *input_int, int size )
{
    TA_ParamHolder *paramHolder;
    const TA_FuncHandle *handle;
    const TA_FuncInfo *funcInfo;
    const TA_InputParameterInfo *inputInfo;
    const TA_OutputParameterInfo *outputInfo;

    TA_RetCode retCode;
    unsigned int i;
    int j;
    int outBegIdx, outNbElement, lookback;

    retCode = TA_GetFuncHandle( funcName, &handle );
    if( retCode != TA_SUCCESS )
    {
        printf( "Can't get the function handle [%d]\n", retCode );
        return TA_ABS_TST_FAIL_GETFUNCHANDLE;
    }

    retCode = TA_ParamHolderAlloc( handle, &paramHolder );
    if( retCode != TA_SUCCESS )
    {
        printf( "Can't allocate the param holder [%d]\n", retCode );
        return TA_ABS_TST_FAIL_PARAMHOLDERALLOC;
    }

    TA_GetFuncInfo( handle, &funcInfo );

    for( i=0; i < funcInfo->nbInput; i++ )
    {
        TA_GetInputParameterInfo( handle, i, &inputInfo );
        switch(inputInfo->type)
        {
        case TA_Input_Price:
            TA_SetInputParamPricePtr( paramHolder, i,
                                      inputInfo->flags&TA_IN_PRICE_OPEN?input:NULL,
                                      inputInfo->flags&TA_IN_PRICE_HIGH?input:NULL,
                                      inputInfo->flags&TA_IN_PRICE_LOW?input:NULL,
                                      inputInfo->flags&TA_IN_PRICE_CLOSE?input:NULL,
                                      inputInfo->flags&TA_IN_PRICE_VOLUME?input_int:NULL, NULL );
            break;
        case TA_Input_Real:
            TA_SetInputParamRealPtr( paramHolder, i, input );
            break;
        case TA_Input_Integer:
            TA_SetInputParamIntegerPtr( paramHolder, i, input_int );
            break;
        }
    }

    for( i=0; i < funcInfo->nbOutput; i++ )
    {
        TA_GetOutputParameterInfo( handle, i, &outputInfo );
        switch(outputInfo->type)
        {
        case TA_Output_Real:
            TA_SetOutputParamRealPtr(paramHolder,i,&output[i][0]);
            for( j=0; j < 2000; j++ )
                output[i][j] = TA_REAL_MIN;
            break;
        case TA_Output_Integer:
            TA_SetOutputParamIntegerPtr(paramHolder,i,&output_int[i][0]);
            for( j=0; j < 2000; j++ )
                output_int[i][j] = TA_INTEGER_MIN;
            break;
        }
    }

    /* Do the function call. */
    retCode = TA_CallFunc(paramHolder,0,size-1,&outBegIdx,&outNbElement);
    if( retCode != TA_SUCCESS )
    {
        printf( "TA_CallFunc() failed zero data test [%d]\n", retCode );
        TA_ParamHolderFree( paramHolder );
        return TA_ABS_TST_FAIL_CALLFUNC_1;
    }

    /* Verify consistency with Lookback */
    retCode = TA_GetLookback( paramHolder, &lookback );
    if( retCode != TA_SUCCESS )
    {
        printf( "TA_GetLookback() failed zero data test [%d]\n", retCode );
        TA_ParamHolderFree( paramHolder );
        return TA_ABS_TST_FAIL_CALLFUNC_2;
    }

    if( outBegIdx != lookback )
    {
        printf( "TA_GetLookback() != outBegIdx [%d != %d]\n", lookback, outBegIdx );
        TA_ParamHolderFree( paramHolder );
        return TA_ABS_TST_FAIL_CALLFUNC_3;
    }

    for( i=0; i < funcInfo->nbOutput; i++ )
    {
        switch(outputInfo->type)
        {
        case TA_Output_Real:
            for( j=0; j < outNbElement; j++ )
            {
                if( trio_isnan(output[i][j]) ||
                        trio_isinf(output[i][j]))
                {
                    printf( "Failed for output[%d][%d] = %e\n", i, j, output[i][j] );
                    return TA_ABS_TST_FAIL_INVALID_OUTPUT;
                }
            }
            break;
        case TA_Output_Integer:
            break;
        }
    }

    /* Do another function call where startIdx == endIdx == 0.
     * In that case, outBegIdx should ALWAYS be zero.
     */
    retCode = TA_CallFunc(paramHolder,0,0,&outBegIdx,&outNbElement);
    if( retCode != TA_SUCCESS )
    {
        printf( "TA_CallFunc() failed data test 4 [%d]\n", retCode );
        TA_ParamHolderFree( paramHolder );
        return TA_ABS_TST_FAIL_CALLFUNC_4;
    }

    if( outBegIdx != 0 )
    {
        printf( "failed outBegIdx=%d when startIdx==endIdx==0\n", outBegIdx );
        TA_ParamHolderFree( paramHolder );
        return TA_ABS_TST_FAIL_STARTEND_ZERO;
    }

    retCode = TA_ParamHolderFree( paramHolder );
    if( retCode != TA_SUCCESS )
    {
        printf( "TA_ParamHolderFree failed [%d]\n", retCode );
        return TA_ABS_TST_FAIL_PARAMHOLDERFREE;
    }

    return TA_TEST_PASS;
}