I cannot get this simple code to work ! PLEASE HELP...

 

Hi people,

I am struggling with this:

int mlevel1upper;

double rangeup[13];

for(int vx=0;vx<13;vx++)

{

rangeup[vx]=Zone1Upper-m_line[vx];

mlevel1upper=ArrayMinimum(rangeup,WHOLE_ARRAY,0);

//double MaxRange=(High[Max]-Low[Max])/Point;

}

Why do I need this? Because ArrayBsearch doesn't work as expected...

What do I expect it to do?

Basically I want it to create an array called rangeup, which has 13 elements. then I want it to compute ranges between Zone1Upper static value (double) and a double value pulled from an array (sorted). So I will get an unsorted array rangeup. And then within this array i want to find the smallest range. So I use ArrayMinimum which should give me the index of the smallest range. However it does not work.

Thanks for help....

 
rookie_forawhile:
Hi people,

I am struggling with this:

int mlevel1upper;

double rangeup[13];

for(int vx=0;vx<13;vx++)

{

rangeup[vx]=Zone1Upper-m_line[vx];

mlevel1upper=ArrayMinimum(rangeup,WHOLE_ARRAY,0);

//double MaxRange=(High[Max]-Low[Max])/Point;

}

Why do I need this? Because ArrayBsearch doesn't work as expected...

What do I expect it to do?

Basically I want it to create an array called rangeup, which has 13 elements. then I want it to compute ranges between Zone1Upper static value (double) and a double value pulled from an array (sorted). So I will get an unsorted array rangeup. And then within this array i want to find the smallest range. So I use ArrayMinimum which should give me the index of the smallest range. However it does not work.

Thanks for help....

rookie_forawhile

Try like this :

//------------------------------------------------------------

//

//------------------------------------------------------------

#property indicator_chart_window

double values[15]={4,1,6,3,19,4,2,6,3,9,4,5,6,3,9};

//------------------------------------------------------------

//

//------------------------------------------------------------

//

//

//

//

//

int init() { return(0); }

int deinit() { return(0); }

int start()

{

int min = ArrayMinimum(values,WHOLE_ARRAY,0);

int max = ArrayMaximum(values,WHOLE_ARRAY,0);

Comment(min," ",values[min]," ",max," ",values[max]);

return(0);

}

Unlike some other array functions, ArrayMinimum and ArrayMaximum are working correctly

 
rookie_forawhile:
Hi people,

I am struggling with this:

int mlevel1upper;

double rangeup[13];

for(int vx=0;vx<13;vx++)

{

rangeup[vx]=Zone1Upper-m_line[vx];

mlevel1upper=ArrayMinimum(rangeup,WHOLE_ARRAY,0);

//double MaxRange=(High[Max]-Low[Max])/Point;

}

Why do I need this? Because ArrayBsearch doesn't work as expected...

What do I expect it to do?

Basically I want it to create an array called rangeup, which has 13 elements. then I want it to compute ranges between Zone1Upper static value (double) and a double value pulled from an array (sorted). So I will get an unsorted array rangeup. And then within this array i want to find the smallest range. So I use ArrayMinimum which should give me the index of the smallest range. However it does not work.

Thanks for help....

If you wish to have the smallest range, simply fill the array with ranges and sort it. If you sort it ascending, element 0 will contain smallest range. If you sort it descending, element 12 will contain smallest range.

Reason: