#Example_PreviousDaysHL-each_extended_through_expansion
#20170911 - BLT
#Example Highs/Lows from previous days, extended from each day through the right expansion
script philow {
input n = 1;
def ymd = GetYYYYMMDD();
def ok = !IsNaN(close);
def capture = ok and ymd != ymd[1];
def dayCount = CompoundValue(1, if capture
then dayCount[1] + 1
else dayCount[1], 0);
def thisDay = (HighestAll(dayCount) - dayCount) ;
def hh = CompoundValue(1, if thisDay == n and SecondsFromTime(0930) == 0
then high
else if thisDay == n and high > hh[1]
then high
else hh[1] , high);
def hhnan = if IsNaN(close) then hhnan[1] else hh;
plot hhplot = if thisDay == n and SecondsFromTime(0930) < 0
then Double.NaN
else if thisDay <= n
then hhnan
else Double.NaN;
def ll = CompoundValue(1, if thisDay == n and SecondsFromTime(0930) == 0
then low
else if thisDay == n and low < ll[1]
then low
else ll[1] , low);
def llnan = if IsNaN(ll) then llnan[1] else ll;
plot llplot = if thisDay == n and SecondsFromTime(0930) < 0
then Double.NaN
else if thisDay <= n
then (llnan)
else Double.NaN;
}
#Plots of Highs/Lows based upon script...add more days using similar plot statements, increasing the value by 1
plot H1 = philow(1);
plot H2 = philow(2);
plot H3 = philow(3);
plot L1 = philow(1).llplot;
plot L2 = philow(2).llplot;
plot L3 = philow(3).llplot;
defineGlobalColor("H",color.red);
defineGlobalColor("L",color.green);
H1.setdefaultColor(globalColor("H"));
H2.setdefaultColor(globalColor("H"));
H3.setdefaultColor(globalColor("H"));
L1.setdefaultColor(globalColor("L"));
L2.setdefaultColor(globalColor("L"));
L3.setdefaultColor(globalColor("L"));