It's determined by whether a trade goes off higher or lower than the previous trade. Once it trades at a higher sp, for example, that trade and all subsequent trades will be classified as "buys".
Click on the "TRADES" icon on any stock board and you can see it in action.
Also, click Help on the Trades page, there's this text there, as well as other useful information:
The 'Buy', 'Sell' and '?' columns - Where the 'Price' is closest to the 'Offer' price, the trade is considered a 'Buy'. Where it is closest to the 'Bid' price, the trade is considered to be a 'Sell'. Where it is dead centre between 'Bid' and 'Offer', it appears in the '?' column; this indicates that the trade cannot be identified as either a 'Buy' or a 'Sell'.