Download MetaTrader 5

Array out of range / ArrayResize problem (yes again im sorry) - page 2

To add comments, please log in or register
Carl Schreiber
7577
Carl Schreiber  

The problem is your program logic to resize the array there is something wrong.

Go through your code using the debugger and look always at the size of your arrays when where and how do you change it!

ffoorr
1115
ffoorr  

try to print the size of the array

Jason Crossfield
155
Jason Crossfield  

Solved thanks gooly and ffoorr for your input.

 

My problem was using the ArrayResize variable when setting the Array values without a de-increment -1 to align with Array index sequence. 

 

So I was using this:

ArrayResize(Closed,++closecnt);
Closed[closecnt][0] = "one";

 

When the correct method is:

 

ArrayResize(Closed,++closecnt);
Closed[closecnt-1][0] = "one";
ffoorr
1115
ffoorr  
yep that's right
whroeder1
16353
whroeder1  
This is wrong. You want to increase the size to one and set element zero
    closecnt=closecnt++;
    ArrayResize(Closed,closecnt);
:
    Closed[closecnt][0]="one";
Like this.
//    closecnt=closecnt++;
    ArrayResize(Closed,closecnt+1);
:
    Closed[closecnt][0]="one";
    ++closecnt; // Now you have one.
Jason Crossfield
155
Jason Crossfield  
Got it thanks WHRoeder :-)
12
To add comments, please log in or register