Creating script to show open price of exact time

 

Hello guys, 

I am newbie here. I feel like this script should be very easy, but i don't get it why it don't work. 
I want to write script which would give me open price of exact time. Let's say i start script 8:00 and i want that at 13:00 it would give me open price of bar at 13:00.

 It's part of my scirpt:

  while(TimeHour(TimeCurrent())<13){;}

  while(TimeMinute(TimeCurrent())<00){;}

  open=DoubleToString(iOpen[0],4);

As i understand what should happen is: 1: it would wait till 13 hour 2. It would wait till 00 minute 3. It would give my current open (13"00 open). Instead i get 8:00 open. Why? 

Reason: