Daily profit and loss

I am looking for a code snippet that would help me calculate daily profit and loss using realized and unrealized profit. Thanks.

it’s already exists in the main account dashboard

Hello,

		//MaxProfit & MaxLoss
		//------------------------------------------------------------------------------
		if (((SystemPerformance.AllTrades.TradesPerformance.Currency.CumProfit - CumProfitTmp) >= MaxProfit)
			|| ((SystemPerformance.AllTrades.TradesPerformance.Currency.CumProfit - CumProfitTmp) <= -MaxLoss))
		{
			DayIsOK = false;
			
			Print(@".....................................");
			Print("DayIsOK ="+Convert.ToString(DayIsOK));
			Print("CumProfitTmp ="+Convert.ToString(CumProfitTmp));
			Print("CumProfit ="+Convert.ToString(SystemPerformance.AllTrades.TradesPerformance.Currency.CumProfit));
		}
		
		
		//------------------------------------------------------------------------------
		//Variables Reset
		//------------------------------------------------------------------------------
		//if (Times[0][0].TimeOfDay == new TimeSpan(0, 0, 0)) //< Times[0][1].TimeOfDay) //== new TimeSpan(0, 0, 0))
		if (Times[0][0].TimeOfDay < Times[0][1].TimeOfDay)
		{
			DayIsOK = true;
			CumProfitTmp = SystemPerformance.AllTrades.TradesPerformance.Currency.CumProfit; 
			TradesCumProfit = SystemPerformance.AllTrades.TradesPerformance.Currency.CumProfit - CumProfitTmp;				
		}