Let me see if I understand your ACTUAL question here (you have asked too specific a question.):
You would like to make make a comparison based on limits obtained through another comparison? Please let me know if I have understood your problem.
If in fact you want to have "dynamic limits", then the method you suggested (dynamic code) is not the answer, but there is in fact a way to do this. All you do is create logic for the limits used in your logic. This is another 'dimension' or level, as they are commonly called, of logic in your program.
Your program itself cannot be dynamic, that is, you cannot have code that changes based on values of certain variables. But, you can create code that affects the same results, you just have to plan ahead, and
create the logic.
Allow me to illustrate:
Let's say you want to generate a boolean of True if variable X is > 2, and false otherwise. However; if variable Y is < 0, you want to compare X to 5 instead of 2. All you do is compare Y first, then, dependent upon the output of this comparison, you will either compare X to 2, or to 5.
Please let me know if this answers your actual question.