This formula is looking into the future but not at future price/volumes simply at the number of bars left.
Barindex() is simply the number of bars since quotation of the stock began
LastValue(BarIndex()) Is always equal to the barindex on the last day of quotation.
If you graph these it will make more sense.
So,
Sell = .........
OR BarIndex() == (LastValue(BarIndex())-1);
Simply generates a sell signal the day before the stocks last quote (When it is delisted), and with trade delay set to 1, sells on the last quote.
Buy = ..........
AND BarIndex() < (LastValue(BarIndex())-1);
Stops you from buying in the day before a stock is delisted or on the day it is delisted (As the sell signal would never be generated) , this only happens in a few corner cases.
Harro