Welkin
Active member
How to split After-hours and Pre-market volumes separately? The following gives both the volumes combined.. the logic is a bit cryptic.. Can someone help? Thanks!
def conf = SecondsFromTime(0930) >= 0 and SecondsFromTime(1600) <= 0;
def ExtVol = if !conf and conf[1] then volume else if !conf then CompoundValue(1, ExtVol[1] + volume, volume) else ExtVol[1];
try this
Code:
input showAftermarket = yes;
input showPremarket = yes;
input rthStart = 0930;
input rthEnd = 1609;
input pmStart = 0400;
input amEnd= 1959;
def NA = Double.NaN;
def amConf = SecondsFromTime(rthEnd) >= 0 and SecondsFromTime(amEnd) <= 0;
def pmConf = SecondsFromTime(pmStart) >= 0 and SecondsFromTime(rthStart - 1) <= 0;
def amVol = if amConf and !amConf[1] and showAftermarket then volume else if amConf and showAftermarket then CompoundValue(1, amVol[1] + volume, volume) else NA;
def pmVol = if pmConf and !pmConf[1] and showPremarket then volume else if pmConf and showPremarket then CompoundValue(1, pmVol[1] + volume, volume) else NA;
plot amV = amVol;
plot pmV = pmVol;
amV.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
pmV.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
amV.AssignValueColor(if close > open then Color.GREEN else Color.RED);
pmV.AssignValueColor(if close > open then Color.GREEN else Color.RED);