Download MetaTrader 5

How does iCCI or iRSI function handle negative values in its shift parameter

To add comments, please log in or register
Having questions? Ask them on the Forum - traders will help you!
sammcdj
32
sammcdj 2016.10.07 18:29 

Hello friends

Embedded below is small snippet of code that has me flummoxed ad confused me to the core.

Declared Variables a0 .... a6 are double (non arrays)

Variable i is integral loop variable that will start from the last unfinished bar and terminate at most recent bar. During debugging, it is very rare to see value of limit anything above 2.

Therefore,

if i is set to 2, expression computing a5 which uses expression "i-5" will pass negative 3 to iCCI function and positive 7 to iRSI function.

if i is set to 1, expression computing a5 which uses expression "i-5" will pass negative 4 to iCCI function and positive 6 to iRSI function.

if i is set to 0, expression computing a5 which uses expression "i-5" will pass negative 5 to iCCI function and positive 5 to iRSI function.

When positive values is passed to iCCI and iRSI they return proper values of same array specified bars ago.

How does iCCI function handle negative values in shift parameter?

double a=0,a1=0,a2=0,a3=0,a4=0,a5=0,a6=0,a7=0,a8=0;
double tt1max=0;
....
//---- buffers to plot data on indicator
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
....
int start()
{
   int limit=Bars-IndicatorCounted();
  
   for(int i=limit-1; i>=0; i--)
   {      a0 =(iCCI(NULL,0,CCI_per,PRICE_TYPICAL,i  )-iRSI(NULL,0,RSI_per,PRICE_TYPICAL,i  ));
      a1=(iCCI(NULL,0,CCI_per,PRICE_TYPICAL,i-1)-iRSI(NULL,0,RSI_per,PRICE_TYPICAL,i+1));
      a2=(iCCI(NULL,0,CCI_per,PRICE_TYPICAL,i-2)-iRSI(NULL,0,RSI_per,PRICE_TYPICAL,i+2));
      a3=(iCCI(NULL,0,CCI_per,PRICE_TYPICAL,i-3)-iRSI(NULL,0,RSI_per,PRICE_TYPICAL,i+3));
      a4=(iCCI(NULL,0,CCI_per,PRICE_TYPICAL,i-4)-iRSI(NULL,0,RSI_per,PRICE_TYPICAL,i+4));
      a5=(iCCI(NULL,0,CCI_per,PRICE_TYPICAL,i-5)-iRSI(NULL,0,RSI_per,PRICE_TYPICAL,i+5));

      tt1max=a0+a1+a2+a3+a4+a5;
      ExtMapBuffer3[i]=tt1max;
   }
   for(i=0; i<limit; i++)
   {    
      ExtMapBuffer1[i]=iMAOnArray(ExtMapBuffer3,Bars,Ma_Period,0,MODE_SMA,i); //  MA (SUM(cci - rsi, koef), ma_period)
   }                 
   return(0);
}
Alain Verleyen
Moderator
30742
Alain Verleyen 2016.10.07 20:41  

How does iCCI function handle negative values in shift parameter?

1° Doesn't really matter as that doesn't make sense, a negative index is in the future.

2° The value will be 0.

To add comments, please log in or register