input OrBegin = 0930.0; #hint OrBegin: Beginning for Period of Opening Range Breakout.
input OrEnd = 1000.0; #hint OrEnd: End of Period of Opening Range Breakout.
def ORActive2 = if secondsTillTime(OREnd) > 0 and
secondsFromTime(ORBegin) >= 0
then 1
else 0;
# This will only be true on bars found in the current day
def today = if getDay() == getLastDay() and
secondsFromTime(OrBegin) >= 0
then 1
else 0;
# This is the cumulative volume for the current day between OrBegin and OrEnd
def cumVolume = if ORActive2 and !ORActive2[1]
then volume[1]
else if ORACtive2 then cumVolume[1] + volume[1]
else cumVolume[1];
# This is the average cumulative volume over the same time period from the previous 5 days
def cumVolumePrev = if ORActive2 and !ORActive2[1]
then (volume[(78*1)+1] + volume[(78*2)+1] + volume[(78*3)+1] + volume[(78*4)+1] + volume[(78*5)+1] ) / 5
else if ORACtive2 then cumVolumePrev[1] + (volume[(78*1)+1] + volume[(78*2)+1] + volume[(78*3)+1] + volume[(78*4)+1] + volume[(78*5)+1] ) / 5
else cumVolumePrev[1];
def barNumber = if ORActive2 and !OrActive2[1]
then 1
else if ORActive2 then barNumber[1] + 1
else barNumber[1];
plot Data1 = if GetAggregationPeriod() == AggregationPeriod.FIVE_MIN and ( ORActive2 or !today) then cumVolume / Min( barNumber, 6) else double.NaN ;
plot Data2 = if GetAggregationPeriod() == AggregationPeriod.FIVE_MIN and (ORActive2 or !today) then cumVolumePrev / Min( barNumber, 6) else double.NaN ;
addCloud(Data1,Data2,createColor(66,160,100),createColor(244,83,66));