Download MetaTrader 5

Can an iCustom call trigger an out of range error?

To add comments, please log in or register
Use searching on MQL5.community. It is easy!
Arturo Lopez Perez
161593
Arturo Lopez Perez 2013.08.24 12:41 

Good morning,

I am having a little poltergeist again. I am working with another piece of code which needs the ZigZag indicator. So I created a handle and a buffer for it.

My code only contains an iCustom call to create the handle, there is no copybuffer being called yet nowhere.  At runtime, this error is thrown.

Any ideas? Thanks.

2013.08.24 12:35:32    ZigZag (EURUSD,D1)    array out of range in 'ZigZag.mq5' (192,32)


This is my code, inside the OnInit function:

ZZHandle = iCustom(_Symbol, 0, "Examples\\ZigZag", ZZ1, ZZBack, ZZDev);
if(ZZHandle == INVALID_HANDLE) return(INIT_FAILED);
This  error only happens when the ZZ1 variable is less than 6, and randomly.
Alain Verleyen
Moderator
30739
Alain Verleyen 2013.08.24 12:52  
PzTrading:

Good morning,

I am having a little poltergeist again. I am working with another piece of code which needs the ZigZag indicator. So I created a handle and a buffer for it.

My code only contains an iCustom call to create the handle, there is no copybuffer being called yet nowhere.  At runtime, this error is thrown.

Any ideas? Thanks.

2013.08.24 12:35:32    ZigZag (EURUSD,D1)    array out of range in 'ZigZag.mq5' (192,32)


This is my code, inside the OnInit function:

There is a bug in ZigZag indicator in this case, I have already reported it to Service Desk.

The problem arises when ExtDepth (1st) input parameter is lower than ExtBackstep (3rd) input parameter. I applied to following correction :

//--- set start position for calculations
   if(prev_calculated==0) limit=MathMax(ExtDepth, ExtBackstep);

in place of

//--- set start position for calculations
   if(prev_calculated==0) limit=ExtDepth;
Arturo Lopez Perez
161593
Arturo Lopez Perez 2013.08.24 13:03  
angevoyageur:

There is a bug in ZigZag indicator in this case, I have already reported it to Service Desk.

The problem arises when ExtDepth (1st) input parameter is lower than ExtBackstep (3rd) input parameter. I applied to following correction :

in place of

Wow, thanks. I spent quite some time on this!
Arturo Lopez Perez
161593
Arturo Lopez Perez 2013.08.24 14:07  
angevoyageur:

There is a bug in ZigZag indicator in this case, I have already reported it to Service Desk.

The problem arises when ExtDepth (1st) input parameter is lower than ExtBackstep (3rd) input parameter. I applied to following correction :

in place of

Finally I got the complete thing to work! Thanks angevoyageur! It has been quite a trip since I started with mql5 some days ago.


Alain Verleyen
Moderator
30739
Alain Verleyen 2013.08.24 14:32  
PzTrading:

Finally I got the complete thing to work! Thanks angevoyageur! It has been quite a trip since I started with mql5 some days ago.


You are welcome.
To add comments, please log in or register