Is this a rocket science?
At the time that you first posted this, I didn't really have the time to sit down and see if there was a better way or not. Any time I see a single record storing a series of fields that store apparently identical data, my first thought is to see if using a table of related records with one record in place of each field might offer options that a set of fields in the same record doesn't have--such as sorting the records, using ExecuteSQL, or using a relationship to match to only certain values of the total set...
In your case, I still have questions about what you are trying to do here.
Focusing just on the H values for a start, it appears that you want 2 values that are:
a) greater than price
b) have a difference where the absolute value of H value 1 - H value 2 is less than 1.005 * Min ( H value 1 ; H value 2)
c) are closer to Price than any other two H values.
Do I have that correctly stated?
Obviously the need to evaluate pairs of highs and pairs of lows makes this such a complicated process. When comparing these pairs do you need to evaluate all possible pairings of the high values or only adjacent values in the list. It appears that you need to evaluate all possible pairings and this is what makes this process tedious.
Hi Aivaras, I think I can help you, cause we are in the same city and we can talk about this solution in more details. It does not realy clear what is the purpose of this calculation. It may be more easier ways to manage the same problem.
Please contact me as I am a FileMaker developer in Vilnius. My email: firstname.lastname@example.org