AFL Code to show Cumulative Vol for PM, In-Market, AH and Overall Total Vol

Greetings All,
I've tried searching throughout here but wasn't able to find what I am searching for, so I'm reaching out to the community. What I am trying to do is have a running total of each of the cumulative volume categories: Premarket, In-Market, Aftermarket and Overall Cumulative for all three. My programming skills are quite novice at best, so any advice is certainly welcomed positively. My code so far and the screen output is shown below:

dn = DateNum();
FirstBar = dn != Ref( dn, -1 );
tn = TimeNum();
daystart = tn > 000000;
dayfinish = tn < 235959;
pre_market = tn < 93000;
after_market = tn > 160000;
MarketOpen = pre_market != Ref(pre_market,-1);
MarketClose = after_market != Ref (after_market,-1);
newDay = dn != Ref( dn, -1 );
PMsum = SumSince ( tn > 93000, V ); // Cumulative PreMarket Volume
VOLsum = SumSince ( pre_market, V );  // Cumulative Daily Volume
AHsum = SumSince ( dayfinish, V); // + ValueWhen( after_market, V); // Cumulative AfterHours Volume
Chg=Ref(C,-1);
Title = EncodeColor(ColorRGB(0,240,255))+ "Ticker: " + EncodeColor(colorOrange) + Name() + 
	EncodeColor(ColorRGB(0,240,255)) + "    Company Name: " + EncodeColor(colorOrange) + FullName() + "    " +
	EncodeColor(colorGold) + "Date: "  + Date() + EncodeColor(colorTan) + "\n{{INTERVAL}}  " +
	EncodeColor(ColorRGB(0,240,255))+ "   Open:  "+ EncodeColor(colorWhite)+ WriteVal(O,format=1.2) + 
	EncodeColor(ColorRGB(0,240,255))+ "   High:  "+ EncodeColor(colorWhite) + WriteVal(H,format=1.2) +
	EncodeColor(ColorRGB(0,240,255))+ "   Low:  "+ EncodeColor(colorWhite)+ WriteVal(L,format=1.2) + 
	EncodeColor(ColorRGB(0,240,255))+ "   Close:  "+ WriteIf(C> Chg,EncodeColor(colorLime),EncodeColor(colorRed))+ WriteVal(C,format=1.2)+
	EncodeColor(ColorRGB(0,240,255))+ "   Change:  "+ WriteIf(C> Chg,EncodeColor(colorLime),EncodeColor(colorRed))+ WriteVal(ROC(C,1),format=1.2)+ "%" +
	EncodeColor(ColorRGB(195,158,255))+ "   Bar Volume: " + EncodeColor(colorWhite) + WriteVal(V,1)+ "\n" + 
	EncodeColor(colorLightBlue) + "    PM Volume: " + WriteVal(PMsum,1) + EncodeColor(colorGold) + "    In-Market Volume:  " + WriteVal(vsum,1) +
	EncodeColor(ColorBlend( colorRed, colorBlack, 0.20))+ "    AH Volume: " + WriteVal(AHsum,1) + 
	EncodeColor(colorGold) + "   Cumulative Daily Volume: " + 	WriteVal(PMsum + VOLsum + AHsum,1)

image

So I've played around with the code a bit more and tried to consolidate a few things. My modified code is as below:

dn = DateNum();
FirstBar = dn != Ref( dn, -1 );
tn = TimeNum();
daystart = tn >= 000000;
dayfinish = tn < 235959;
pre_market = tn > 92959;
in_market = tn > 155959;
after_market = tn < 235959;
PMsum = SumSince ( pre_Market , V);		// Cumulative PreMarket Volume
InMsum = SumSince ( In_Market , V) - (SumSince (After_Market, V));	// Cumulative InMarket Volume
AHsum = SumSince ( after_market , V); 								// Cumulative AfterHours Volume
VOLsum = SumSince ( FirstBar , V ) + ValueWhen (FirstBar, V);  		// Total Cumulative Daily Volume

Title = EncodeColor(ColorRGB(0,240,255))+ "Ticker: " + EncodeColor(colorOrange) + Name() + 
	EncodeColor(ColorRGB(0,240,255)) + "    Company Name: " + EncodeColor(colorOrange) + FullName() + "    " +
	EncodeColor(colorGold) + "Date: "  + Date() + EncodeColor(colorTan) + "\n{{INTERVAL}}  " +
	EncodeColor(ColorRGB(0,240,255))+ "   Open:  "+ EncodeColor(colorWhite)+ WriteVal(O,format=1.2) + 
	EncodeColor(ColorRGB(0,240,255))+ "   High:  "+ EncodeColor(colorWhite) + WriteVal(H,format=1.2) +
	EncodeColor(ColorRGB(0,240,255))+ "   Low:  "+ EncodeColor(colorWhite)+ WriteVal(L,format=1.2) + 
	EncodeColor(ColorRGB(0,240,255))+ "   Close:  "+ WriteIf(C> Chg,EncodeColor(colorLime),EncodeColor(colorRed))+ WriteVal(C,format=1.2)+
	EncodeColor(ColorRGB(0,240,255))+ "   Change:  "+ WriteIf(C> Chg,EncodeColor(colorLime),EncodeColor(colorRed))+ WriteVal(ROC(C,1),format=1.2)+ "%" +
	EncodeColor(ColorRGB(195,158,255))+ "   Bar Volume: " + EncodeColor(colorWhite) + WriteVal(V*100,1)+ "\n" + 
	EncodeColor(colorLightBlue) + "    PM Volume: " + WriteVal(PMsum*100,1) + EncodeColor(colorGold) + "    In-Market Volume:  " + WriteVal(InMsum*100,1) +
	EncodeColor(ColorBlend( colorRed, colorBlack, 0.20))+ "    AH Volume: " + WriteVal(AHsum*100,1) + 
	EncodeColor(colorGold) + "   Cumulative Daily Volume: " + 	WriteVal((VOLsum)*100,1)

I've also looked at the code that was provided in this thread regarding intraday cumulative volume:
[Intraday cumulative volume]
This solved the one portion of the Total Cumulative Daily Volume for the day, but looking at the other cumulative volumes (premarket, Intraday, and After Hours) I don't understand why it is that when the time frame crosses at tn > 93000, the cumulative value for the premarket (eg. the value of PMsum) goes back to 0. Basically what I want it to represent is that when it crosses the tn > 93000, the value of PMsum I want to be the cumulative value up to that point. After tn > 93000, the value of the In_Market volume I want to start increasing from zero. Similarly, at the end of the trading day at tn = 160000, I want it to show the In-Market value at that point to represent the cumulative Volume between 93000 < tn < 160000. And Finally, Any after-hours trading volume I want cumulatively shown summated from tn > 160000. I've looked into multiple threads on the matter, but can only find partial solutions for what I'm looking for. I'm wondering if I need to be using something other than SumSince, or if a for loop would be able to wrap things up tidily to do this. Any guidance in this regard is much appreciated.

Can anyone provide some insight? Just not sure I understand how the SumSince function works in particular.