#after_hours_vol
#https://usethinkscript.com/threads/how-to-get-after-hours-trading-volume.20098/
#How to get after hours trading volume
def na = double.nan;
def bn = barnumber();
def v = volume;
input prestart = 0400;
input daystart = 0930;
input dayend = 1600;
input afterend = 2000;
def pre = (SecondsFromTime(prestart) >= 0 and SecondsTillTime(daystart) > 0);
def daytime = (SecondsFromTime(daystart) >= 0 and SecondsTillTime(dayend) > 0);
def after = (SecondsFromTime(dayend) >= 0 and SecondsTillTime(afterend) > 0);
def prevol = if !pre[1] and pre then v else if pre then prevol[1] + v else prevol[1];
def dayvol = if !daytime[1] and daytime then v else if daytime then dayvol[1] + v else dayvol[1];
def aftervol = if !after[1] and after then v else if after then aftervol[1] + v else aftervol[1];
addlabel(1, " ", color.black);
addlabel(1, "PRE volume: " + prevol, color.cyan);
addlabel(1, "DAY volume: " + dayvol, color.green);
addlabel(1, "AFTER volume: " + aftervol, color.magenta);
addlabel(1, " ", color.black);
input test_time_lines = no;
addverticalline(test_time_lines and pre, "PRE", color.cyan);
addverticalline(test_time_lines and daytime, "DAY", color.green);
addverticalline(test_time_lines and after, "AFTER", color.magenta);
input test_volume_lines = no;
plot z1 = if test_volume_lines then prevol else na;
plot z2 = if test_volume_lines then dayvol else na;
plot z3 = if test_volume_lines then aftervol else na;
#