Getting LastBar intraday

I created the following afl:

startTime = 90000; 
endTime = 220000; 

Buy = TimeNum() <= startTime;
Sell = TimeNum() >= endTime;

My problem with this is, sometimes the exchanges closes earlier then 22:00:00.
So how can I get the last bar intraday independently the exchange closes.

Here is one way:

isEndOfDay = TimeFrameExpand(1, inDaily, expandPoint);
Sell = isEndOfDay;

Thank you mradtke, that works perfect!