How is the buy average affected when shares from holdings are sold and bought back on the same day?
Your buy average (or average cost) is based solely on the price and quantity of shares actually in your demat account at settlement.
Note: The buy average calculation is unaffected by intraday trades, since those shares never physically move in or out of your holdings.