I coded an EA. But i always getting "array out of range (85,11)" error. Please help me.

 

Hi guys,

Here is my code.

Please help me. 

double ilkuclu[],ikinciuclu[];
double yuzdefark[];
double fiyatlar[];
ArraySetAsSeries(fiyatlar,true);
CopyClose(NULL,PERIOD_M5,0,11,fiyatlar);
ArraySetAsSeries(ilkuclu,true);
ArraySetAsSeries(ikinciuclu,true);
ArraySetAsSeries(yuzdefark,true);
ilkuclu[8]=NormalizeDouble(((fiyatlar[10]+fiyatlar[9]+fiyatlar[8])/3),_Digits);
ilkuclu[7]=NormalizeDouble(((fiyatlar[9]+fiyatlar[8]+fiyatlar[7])/3),_Digits);
ilkuclu[6]=NormalizeDouble(((fiyatlar[8]+fiyatlar[7]+fiyatlar[6])/3),_Digits);
ilkuclu[5]=NormalizeDouble(((fiyatlar[7]+fiyatlar[6]+fiyatlar[5])/3),_Digits);
ilkuclu[4]=NormalizeDouble(((fiyatlar[6]+fiyatlar[5]+fiyatlar[4])/3),_Digits);
ilkuclu[3]=NormalizeDouble(((fiyatlar[5]+fiyatlar[4]+fiyatlar[3])/3),_Digits);
ilkuclu[2]=NormalizeDouble(((fiyatlar[4]+fiyatlar[3]+fiyatlar[2])/3),_Digits);
ilkuclu[1]=NormalizeDouble(((fiyatlar[3]+fiyatlar[2]+fiyatlar[1])/3),_Digits);
ilkuclu[0]=NormalizeDouble(((fiyatlar[2]+fiyatlar[1]+fiyatlar[0])/3),_Digits);
ikinciuclu[6]=NormalizeDouble(((ilkuclu[8]+ilkuclu[7]+ilkuclu[6])/3),_Digits);
ikinciuclu[5]=NormalizeDouble(((ilkuclu[7]+ilkuclu[6]+ilkuclu[5])/3),_Digits);
ikinciuclu[4]=NormalizeDouble(((ilkuclu[6]+ilkuclu[5]+ilkuclu[4])/3),_Digits);
ikinciuclu[3]=NormalizeDouble(((ilkuclu[5]+ilkuclu[4]+ilkuclu[3])/3),_Digits);
ikinciuclu[2]=NormalizeDouble(((ilkuclu[4]+ilkuclu[3]+ilkuclu[2])/3),_Digits);
ikinciuclu[1]=NormalizeDouble(((ilkuclu[3]+ilkuclu[2]+ilkuclu[1])/3),_Digits);
ikinciuclu[0]=NormalizeDouble(((ilkuclu[2]+ilkuclu[1]+ilkuclu[0])/3),_Digits);
yuzdefark[5]=NormalizeDouble(((ikinciuclu[5]*100/ikinciuclu[6])-100)*100000,0);
yuzdefark[4]=NormalizeDouble(((ikinciuclu[4]*100/ikinciuclu[5])-100)*100000,0);
yuzdefark[3]=NormalizeDouble(((ikinciuclu[3]*100/ikinciuclu[4])-100)*100000,0);
yuzdefark[2]=NormalizeDouble(((ikinciuclu[2]*100/ikinciuclu[3])-100)*100000,0);
yuzdefark[1]=NormalizeDouble(((ikinciuclu[1]*100/ikinciuclu[2])-100)*100000,0);
yuzdefark[0]=NormalizeDouble(((ikinciuclu[0]*100/ikinciuclu[1])-100)*100000,0);
 
lightning2006:

Hi guys,

Here is my code.

Please help me. 

You declared your arrays, but you didn't set their size.

You have to either set size at the declaration, or use ArrayResize() function.

Something like this:

// Set size at the declaration
double ilkuclu[10],ikinciuclu[10]; 
double yuzdefark[10];
double fiyatlar[10];

Or this:

// Set size using ArrayResize
double ilkuclu[],ikinciuclu[];
double yuzdefark[];
double fiyatlar[];

ArrayResize(ilkuclu, 10);
ArrayResize(ikinciuclu, 10);
ArrayResize(yuzdefark, 10);
ArrayResize(fiyatlar, 10);
Documentation on MQL5: Array Functions / ArrayResize
Documentation on MQL5: Array Functions / ArrayResize
  • www.mql5.com
ArrayResize - Array Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Drazen Penic #:

You declared your arrays, but you didn't set their size.

You have to either set size at the declaration, or use ArrayResize() function.

Something like this:

Or this:

Thank you. İt worked like that.

 
Drazen Penic #:

You declared your arrays, but you didn't set their size.

You have to either set size at the declaration, or use ArrayResize() function.

Something like this:

Or this:

The new ArrayResize function has: int  reserve_size=0        // reserve size value (excess)