Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 67

 
alexey1979621:

When testing an Expert Advisor in the journal an error pops up

2013.08.07 12:35:41 2012.06.06 05:29 Puria - 1.452 - SQ EURUSD,M30: Error 4002 (array index - out of range)

2013.08.07 12:35:41 2012.06.06 05:29 Puria - 1.452 - SQ EURUSD,M30: Attempting to open a Buy order. Waiting for an answer.

Accordingly, the orders are not opened. How to eliminate the error? What are the reasons?

I would be glad to help.

Without code, I can only suggest that the index pointing to a cell in the array is pointing outside the array. If an array has size 10 and the index has size 10, the index points to the array's non-existent 11th cell, because array indexing starts with zero. For this example: an array of size 10 is indexed from 0 to 9 - a total of 10.

 
Mepkypuu:
Not much will be clear from the terminal messages alone, not much will help you if you don't post the EA code. Somewhere in your array you are writing a non-existent batch of data, as one of the assumptions, but guessing is not my profile.
I got this EA from a friend. I have seen it working without errors in person on Skype. I got error 4002. What else could it be?
 
alexey1979621:
I got this advisor from a friend. It works without any errors, I saw it in person on Skype. I got error 4002. What else could it be?

I have given you an unambiguous answer. You can't fix it without code.
 
r772ra:
You can.

Thank you! Maybe you've seen the public domain?
 
001:
Thank you! Maybe seen in the public domain?

Here
 
alexey1979621:
I got this advisor from a friend. It works without any errors, I saw it in person on Skype. I got error 4002. What else could it be?
Once again, guessing is not my area of expertise. Look at the code, where you write the arrays, work through all the possible ways of collecting data in your mind, and one of them will not exist. It should be excluded in some way. And in general, ask your friend to deal with the error? He's the author of the Expert Advisor, isn't he? It is in his competence to make sure that the code excludes possible execution errors.
 

Can you please tell me how correct such an entry is?

for(int i=ObjectsTotal(OBJ_HLINE)-1; i>=0; i--) 

It will not turn out that when I have, for example, 3 horizontal objects, and a total of 10 objects, and these horizontal objects scattered among the 10, then the search 3 top will be analyzed, but the next 7, which will be all (or part) of the horizontal lines, it will not come? Or will it automatically sort by horizontal lines?

And, if the latter is true, is it possible to make such an entry:

for(int i=ObjectsTotal(OBJ_HLINE && OBJ_TREND)-1; i>=0; i--) 
 
Chiripaha:

Can you please tell me if such an entry is correct:

Couldit be that when I have, for example, 3 horizontal objects, and a total of 10 objects, and these horizontal objects scattered among the 10, then the search 3 top will be analyzed, but the next 7, which will be all (or part) of the horizontal lines, it will not come? Or will it automatically sort by horizontal lines?

And, if the latter is true, is it possible to make such an entry:

for(int i=ObjectsTotal(OBJ_HLINE && OBJ_TREND)-1; i>=0; i--) 

1. It won't work. It will sort by horizontal.

2. Should it?

 
Sort by first and not by horizontal....
 
artmedia70:

1. It won't work. It will sort by horizontal.

2. Should it?

2. I have to. I need to view 2 types of objects: horizontal lines and trend lines. The rest of the objects are not relevant in this search.

FAQ:
Sort by first and not by horizontal....
If I understand correctly, are opinions divided? or does the answer about "firsts" not contradict the previous statement?
Reason: