calculating Total Shareholder Return

Hi all, thought this this would be a good place to ask this finance question.

I want to calculate total return of a stock including dividends reinvested at the ex-date.

I pulled the function in bloomberg, rearranged the formula for clarity, and this is what they use:

[end_price + div*(end_price/ex_price) - begin_price] / [begin_price]

Can someone explain the logic and explanation of the “div*(end_price/ex_price)” thing here? I know it has to do with seeing how much the dividend is worth as the stock price goes up/down because it’s reinvested afterall, but can someone give a better explanation?

thanks!

I think your answer is exactly correct. That part of the formula is calculating the value of the dividend you re-invested at the end of the holding period.