When you do an intraday trade, it is considered as a separate transaction altogether since the shares do no actually move in/out of your demat account. Thus when you sell shares that exist in your investments and buy them back on the same day, there is no movement of shares that would actually happen in your demat account and thus intraday trades like such do not affect your buy average.