Calculating Returns

I am trying to use calculate my realized gains each day without using the current equity/last equity metric. I am going through all my orders in the day and simply subtracting all my sells with my buys however that is giving me a different realized gain than the current/last equity metric. Could someone please advise the best way to backtrack and calculate realized gains for the day based on each trade?