Download MetaTrader 5

ArrayMinumn problem!

To add comments, please log in or register
fly7680
636
fly7680  

Hi, I have a small problem with the ArrayMinum () function, because it can not read the lowest value of the matrices. Instead, if I use ArrayMaximun it works all over again.


//Global Scope
int m=0;
double CLOSE2[8];
//----------------//

for(int L=2; L<10; L++){
               
     if(Open[L] > Close[L]){
                               
       CLOSE2[m]= Close[L]; 
       Print("Close[L]: "+ DoubleToString(CLOSE2[m],5)); 
       m++;
       CloseMin= CLOSE2[ArrayMinimum(CLOSE2)];
       Print("CloseMin: "+DoubleToString(CloseMin,5));
      }
     }
                       
                                      
If I change ArrayMinimun with ArrayMaximun everything works.
Drazen Penic
2703
Drazen Penic  
fly7680:

Hi, I have a small problem with the ArrayMinum () function, because it can not read the lowest value of the matrices. Instead, if I use ArrayMaximun it works all over again.


If I change ArrayMinimun with ArrayMaximun everything works.


CLOSE2 array is probably initialized with zeroes and you fill the array with price values, one by one.

This means that you have at least one zero in the array and that's a minimum value.

If you want to use ArrayMinimum, you need to initialize the array with values higher than any price you will put in (for example DBL_MAX), but don't forget to handle that situation if you use the array before the above loop.

fly7680
636
fly7680  
Drazen Penic:


CLOSE2 array is probably initialized with zeroes and you fill the array with price values, one by one.

This means that you have at least one zero in the array and that's a minimum value.

If you want to use ArrayMinimum, you need to initialize the array with values higher than any price you will put in (for example DBL_MAX), but don't forget to handle that situation if you use the array before the above loop.

Thanks I got initialized so and it works !!!

double CLOSE2[8]={4,5,6,3,19,4,2,6};

I do not understand why, however, with ArrayMaximun (), there is no problem with the variable being altered so.

double CLOSE[8];

CloseMax= CLOSE[ArrayMaximum(CLOSE)];
fly7680
636
fly7680  
Sorry, Now I understand!
To add comments, please log in or register