Manual backtesting afl code

The below code does not produce the desired result and I am stuck at it. Anyone , please help me.
//////////////////////////////////////////////////////////////////////////
isStartOfDay = Day() != Ref(Day(),-1);

COVERRESULT = ShortPrice - CoverPrice;
SELLRESULT = BuyPrice - SellPrice;

numLOSSCOVER = SumSince(isStartOfDay, COVERRESULT < 0);
numPROFITCOVER = SumSince(isStartOfDay, COVERRESULT > 0);
numLOSSSELL = SumSince(isStartOfDay, SELLRESULT < 0);
numPROFITSELL = SumSince(isStartOfDay, SELLRESULT > 0);
numLOSSTRADES = numLOSSCOVER + numLOSSSELL;
numPROFITTRADES = numPROFITCOVER + numPROFITSELL;

GfxTextOut(" , LOSS TRADES = " + numLOSSTRADES , 250,y-60);
GfxTextOut(" , PROFIT TRADES = " + numPROFITTRADES , 335,y-60);
GfxTextOut(" , P/L = " + 0 , 430,y-60);
/////////////////////////
The above code gives total bar count for the day for both numLOSSTRADES & numPROFITTRADES

Also , I have no idea how to code for calculating total profit/loss for the day due to the total number of trades executed.

Experts, please guide and help.