Let me elaborate more the logic.
When current bar close, I want to set next bar to buy if price > current bar high and set stop lose to current bar low.
Let's begin with some trading strategy design basics.
The evaluation of your logic happens in the current bar.
You can ONLY compare the current situation with something happened in the PAST.
Because we do not know the future, we cannot make an evaluation of future events.
Thus I said, you need to organize your thoughts a bit - I know what you mean; it is a matter of timing orientation.
Please re-read my suggestion in the previous post again.