code: public double getTotalReturn() {
  
          Decimal totalProduct = Decimal.ONE;
          int completeTimeframes = (getTimeSeries().getTickCount() / timeFrame);
  
          for (int i = 1; i <= completeTimeframes; i++) {
              int index = i * timeFrame;
              Decimal currentReturn = getValue(index);
  
              // Skip NaN at the end of a series
              if (currentReturn != Decimal.NaN) {
                  currentReturn = currentReturn.plus(Decimal.ONE);
                  totalProduct = totalProduct.multipliedBy(currentReturn);
              }
          }
  
          return (Math.pow(totalProduct.toDouble(), (1.0 / completeTimeframes)));
      }
docs: Gets the TotalReturn from the calculated results of the method 'calculate'.
  For a timeFrame = number of trading days within a year (e. g. 251 days in the US)
  and "end of day"-ticks you will get the 'Annualized Total Return'.
  Only complete timeFrames are taken into the calculation.
  @return the total return from the calculated results of the method 'calculate'