Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

CCI source file needed
 Post subject: CCI source file needed Post rating: 0   New post Posted: Sun 22 Sep, 2013, 09:18 

User rating: 3
Joined: Mon 05 Nov, 2012, 11:56
Posts: 80
Location: Germany,
Hi,

Could someone please give me the CCI indicator Jforex source file (.java) here? I could not find this indicator's source file in any of the Jforex source packages.

Thanks in advance!


 
 Post subject: Re: CCI source file needed Post rating: 2   New post Posted: Sun 22 Sep, 2013, 21:50 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
hi ccadar:

CCI indicator is implemented in TaLib i i'm not in mistake. Below the source part of Core.java refering CCI:

public RetCode cci( int startIdx,
      int endIdx,
      double inHigh[],
      double inLow[],
      double inClose[],
      int optInTimePeriod,
      MInteger outBegIdx,
      MInteger outNBElement,
      double outReal[] )
   {
      double tempReal, tempReal2, theAverage, lastValue;
      int i, j, outIdx, lookbackTotal;
      int circBuffer_Idx = 0; double []circBuffer; int maxIdx_circBuffer = (30-1) ;
      if( startIdx < 0 )
         return RetCode.OutOfRangeStartIndex ;
      if( (endIdx < 0) || (endIdx < startIdx))
         return RetCode.OutOfRangeEndIndex ;
      if( (int)optInTimePeriod == ( Integer.MIN_VALUE ) )
         optInTimePeriod = 14;
      else if( ((int)optInTimePeriod < 2) || ((int)optInTimePeriod > 100000) )
         return RetCode.BadParam ;
      lookbackTotal = (optInTimePeriod-1);
      if( startIdx < lookbackTotal )
         startIdx = lookbackTotal;
      if( startIdx > endIdx )
      {
         outBegIdx.value = 0 ;
         outNBElement.value = 0 ;
         return RetCode.Success ;
      }
      { if( optInTimePeriod <= 0 ) return RetCode.AllocErr ; circBuffer = new double[optInTimePeriod]; maxIdx_circBuffer = (optInTimePeriod-1); } ;
      i=startIdx-lookbackTotal;
      if( optInTimePeriod > 1 )
      {
         while( i < startIdx )
         {
            circBuffer[circBuffer_Idx] = (inHigh[i]+inLow[i]+inClose[i])/3;
            i++;
            { circBuffer_Idx ++; if( circBuffer_Idx > maxIdx_circBuffer ) circBuffer_Idx = 0; } ;
         }
      }
      outIdx = 0;
      do
      {
         lastValue = (inHigh[i]+inLow[i]+inClose[i])/3;
         circBuffer[circBuffer_Idx] = lastValue;
         theAverage = 0;
         for( j=0; j < optInTimePeriod; j++ )
            theAverage += circBuffer[j];
         theAverage /= optInTimePeriod;
         tempReal2 = 0;
         for( j=0; j < optInTimePeriod; j++ )
            tempReal2 += Math.abs (circBuffer[j]-theAverage);
         tempReal = lastValue-theAverage;
         if( (tempReal != 0.0) && (tempReal2 != 0.0) )
         {
            outReal[outIdx++] = tempReal/(0.015*(tempReal2/optInTimePeriod));
         }
         else
            outReal[outIdx++] = 0.0;
         { circBuffer_Idx ++; if( circBuffer_Idx > maxIdx_circBuffer ) circBuffer_Idx = 0; } ;
         i++;
      } while( i <= endIdx );
      outNBElement.value = outIdx;
      outBegIdx.value = startIdx;
      return RetCode.Success ;
   }
   public RetCode cci( int startIdx,
      int endIdx,
      float inHigh[],
      float inLow[],
      float inClose[],
      int optInTimePeriod,
      MInteger outBegIdx,
      MInteger outNBElement,
      double outReal[] )
   {
      double tempReal, tempReal2, theAverage, lastValue;
      int i, j, outIdx, lookbackTotal;
      int circBuffer_Idx = 0; double []circBuffer; int maxIdx_circBuffer = (30-1) ;
      if( startIdx < 0 )
         return RetCode.OutOfRangeStartIndex ;
      if( (endIdx < 0) || (endIdx < startIdx))
         return RetCode.OutOfRangeEndIndex ;
      if( (int)optInTimePeriod == ( Integer.MIN_VALUE ) )
         optInTimePeriod = 14;
      else if( ((int)optInTimePeriod < 2) || ((int)optInTimePeriod > 100000) )
         return RetCode.BadParam ;
      lookbackTotal = (optInTimePeriod-1);
      if( startIdx < lookbackTotal )
         startIdx = lookbackTotal;
      if( startIdx > endIdx )
      {
         outBegIdx.value = 0 ;
         outNBElement.value = 0 ;
         return RetCode.Success ;
      }
      { if( optInTimePeriod <= 0 ) return RetCode.AllocErr ; circBuffer = new double[optInTimePeriod]; maxIdx_circBuffer = (optInTimePeriod-1); } ;
      i=startIdx-lookbackTotal;
      if( optInTimePeriod > 1 )
      {
         while( i < startIdx )
         {
            circBuffer[circBuffer_Idx] = (inHigh[i]+inLow[i]+inClose[i])/3;
            i++;
            { circBuffer_Idx ++; if( circBuffer_Idx > maxIdx_circBuffer ) circBuffer_Idx = 0; } ;
         }
      }
      outIdx = 0;
      do
      {
         lastValue = (inHigh[i]+inLow[i]+inClose[i])/3;
         circBuffer[circBuffer_Idx] = lastValue;
         theAverage = 0;
         for( j=0; j < optInTimePeriod; j++ )
            theAverage += circBuffer[j];
         theAverage /= optInTimePeriod;
         tempReal2 = 0;
         for( j=0; j < optInTimePeriod; j++ )
            tempReal2 += Math.abs (circBuffer[j]-theAverage);
         tempReal = lastValue-theAverage;
         if( (tempReal != 0.0) && (tempReal2 != 0.0) )
         {
            outReal[outIdx++] = tempReal/(0.015*(tempReal2/optInTimePeriod));
         }
         else
            outReal[outIdx++] = 0.0;
         { circBuffer_Idx ++; if( circBuffer_Idx > maxIdx_circBuffer ) circBuffer_Idx = 0; } ;
         i++;
      } while( i <= endIdx );
      outNBElement.value = outIdx;
      outBegIdx.value = startIdx;
      return RetCode.Success ;
   }


Trade well

JL


 
 Post subject: Re: CCI source file needed Post rating: 0   New post Posted: Mon 23 Sep, 2013, 08:11 

User rating: 3
Joined: Mon 05 Nov, 2012, 11:56
Posts: 80
Location: Germany,
Thanks a lot JL!


 

Jump to:  

cron
  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com