Conditions for entering into trade operations

 
I have to check some simple conditions before I can enter the trade (in a moment A I get a pivot, in a moment B the current value of the symbol exceeds the value of my pivot by X pips, in a moment C the current value of the symbol drops by Y pip the value of my pivot, so that A comes before B that comes before C).
I tried to do it with a while (true) and iteratively check the conditions, but when the while kicks in the test freezes (the while keeps running, but the current value does not update and always stops at the same instant).
What are my alternatives? Are there any built-in functions already? Do I have to do it myself? In case, do you have any suggestions for making it work?

In case I had to create one myself, I thought that a possible solution was to insert everything in the OnTick function but since I would not want to lose the pivot information I would need a two-dimensional array, is it possible to create one in MQL5? The array should not contain a fixed number of pivots, but these can vary.