In block 6 you ask "Is there a Buy trade at the moment" and the answer is Yes let's say 25 times... or until that Buy trade gets closed. I don't think I understand what you are trying to do. Normally above "Buy now" or "Sell now" there is "No trade", not "If trade".
R