a problem about ArrayMaximum( )

 

Hi gays.

When I tested my EA,there is a error like this:

"incorrect start position 0 for ArrayMaximum( )";

Can anybody tell me the reason.

Thank you!

A part of the code:

int start()
{
int ticket,total=0,cnt;
int SearchRangeMAofRSI=7;
int SearchRangeRSI=13;

double MAofRSI_0,MAofRSI_1;
double MAofRSI[],RSI[];
double MAofRSItrend[];
double RSItrend[];

MAofRSI_0=iCustom(NULL,0,"MA of RSI",1,0);
MAofRSI_1=iCustom(NULL,0,"MA of RSI",1,1);

total=OrdersTotal();
if(total<1)
{//a
if( MAofRSI_0>=50-deviation && //MAofRSI is in range
MAofRSI_0<MAofRSI_1 )
{//b
ArraySetAsSeries(MAofRSI,true);
ArraySetAsSeries(RSI,true);

for(int i=0;i<SearchRangeMAofRSI;i++)
{
MAofRSI[i]=iCustom(NULL,0,"MA of RSI",1,i);
}
for(i=0;i<SearchRangeRSI;i++)
{
RSI[i]=iCustom(NULL,0,"MA of RSI",0,i);
}
int maxMAofRSIIdx=ArrayMaximum(MAofRSI,SearchRangeMAofRSI,0);
int maxRSIIdx=ArrayMaximum(RSI,SearchRangeRSI,0);

double maxMAofRSIvalue =MAofRSI[maxMAofRSIIdx];
double maxRSIvalue =RSI[maxRSIIdx];

for(i=0;i<maofrsiwhethertrend;i++)
{
MAofRSItrend[i]=iCustom(NULL,0,"MA of RSI",1,i+maxMAofRSIIdx);
}
for(i=0;i<maofrsiwhethertrend-1;i++)
{
if(MAofRSItrend[i]<MAofRSItrend[i+1]) return(0);
}
for(i=0;i<maxMAofRSIIdx-1;i++)
{
if(MAofRSI[i]>MAofRSI[i+1]) return(0);
}

int minRSIIdx=ArrayMinimum(RSI,maxRSIIdx+1,0);
double minRSI_maxRSIIdxto_0=RSI[minRSIIdx];
if(minRSIIdx==0) return(0);

・・・・・・

 

For these arraies:

double MAofRSI[],RSI[];
double MAofRSItrend[];
double RSItrend[];

First you should use

int ArrayResize( void array[], int new_size)

otherwise, they are null array, no any elements.

 
DxdCn wrote >>

For these arraies:

double MAofRSI[],RSI[];
double MAofRSItrend[];
double RSItrend[];

First you should use

int ArrayResize( void array[], int new_size)

otherwise, they are null array, no any elements.

Thank you very much.

帮了大忙!