Array Function

 

Sir,

I am using different indicators and calculations to identify levels of good support and resistance. Most of the time i get 5 or 6 differenet values.

eg: 1. Daily R2

2. BB upper band level, etc..

How to identify the value close to the current bid. Means the lowest value above the current level and the highest value below the current level.

Regards

Noufel

 
Put the values into and array and sort.
#define MAX_SNR X
double SnR[MAX_SNR]; Fill(SnR);

double SnRSorted[MAX_SNR];
for(lines=0; lines < MAX_SNR; lines++){
    for (int idx=lines; idx>0; idx--){          // Insertion sort.
        if (SnRSorted[idx] <= SnR[line]) break;
        SnRSorted[idx] = SnRSorted[idx-1];
    }
    SnRSorted[idx] = SnR[line];                 // Insert.
}
for(lines=0; lines < MAX_SNR; lines++){
   if (SnRSorted[lines] < Bid) break;
}
// Nearest Support    = SnRSorted[lines]
// Nearest Resistance = SnRSorted[lines+1]
 
WHRoeder:
Put the values into and array and sort.

THANK YOU VERY MUCH
Reason: