Array out of Range Even with CopyBuffer

 

Hello. i've got some problems.

The Expert advisors are running 6 months without problem in real account.

I have 10 experts advisors running the same parameter,on the same broker,same MT5 Version,Same timeframe

3 of them gave me the following error :


One of them gave me this error :

(USDJPY,M2) array out of range in 'heiken_ashi.mq5' (72,32)


other Gave me this :

(USDJPY,M2)     array out of range in 'HeikenAshi.mqh' (71,25)


The error is the same,but in different Line.


this is the following code :

63 short HA::getSinal() // 0 pra azul,1 pra vermelho
64 {
65
66  if(CopyBuffer(HeikenAshi_Handler,4,0,3,HeikenAshi_Color) == -1) return -1;
67 ArraySetAsSeries(HeikenAshi_Color,true);
68
69
70
71 return (HeikenAshi_Color[1] == 0) ? 0 : 1;
72
73
74 }


Can someone help me to answers these questions :


1- Why the error is at line 72 if there's nothing there ?
2-how could i get Array out of range if i'm checking the return value of CopyBuffer ?

3- why this error didn't happen with all the EAS if they're using the same broker,same chart,same timeframe,same mt5 version,same parameter ?

Thank you for the attention ! if you have suggest or answer for any question,i would really appreciate it

 
Bilal Said:
 


2-how could i get Array out of range if i'm checking the return value of CopyBuffer ?

2- Try this part of code:

if(CopyBuffer(HeikenAshi_Handler,4,(int)0,3,HeikenAshi_Color) != 3) return -1;
 
Petr Nosek:

2- Try this part of code:


maybe it copied the data but not all of it,with your code should fix it.

thank for the helping me and answering one of the questions.

 
Check the errors, _LastError!
 
Carl Schreiber:
Check the errors, _LastError!

Can't do this because the error was at live account and don't happen while backtesting.

Reason: