Find second strongest value from array

 

     How to find second max/min value from array?  (first down from strongest valute)


     This is my code for max/min values:


           int num_array1[8];

           num_array1[1]=USDstrenght;
           num_array1[2]=EURstrenght;
           num_array1[3]=JPYstrenght;
           num_array1[4]=CADstrenght;      
           num_array1[5]=GBPstrenght;
           num_array1[6]=AUDstrenght;
           num_array1[7]=NZDstrenght;
           num_array1[8]=CHFstrenght;

          int strongvalute=ArrayMaximum(num_array1,WHOLE_ARRAY,0);

          int weakvalute=ArrayMinimum(num_array1,WHOLE_ARRAY,0);

 

      I need:

      int second_strongvalute?

      int second_weakevalute?


 
Find max as you did in your example, make a loop on your array, compare values to find largest one, skip index that was found as max.
 
 ArraySort() will help you to find them 
 
   int arr[] = {1, 2, 3, 4, 5};
   ArraySort(arr, WHOLE_ARRAY, 0, MODE_DESCEND);
   Print("second highest ", arr[1]);
 
I am also having a similar problem. any help. A more detailed help
Sincere thanks!
 

ArraySort() will definitely sort the values. But you might need to identify which symbol the value is associated with?

So you could use a two dimensional array to store some kind of symbol id as well...

Something like this

double myarray[28,2];  // value, symbolid

myarray[0,0]=USDStrength;
myarray[0,1]=USDSymId;
myarray[1,0]=EURStrength;
myarray[1,1]=EURSymId;
// etc


Then, ArraySort() as suggested, which only sorts on the first array element, which you would make the strength value.

Reason: