here is a study to plot high low levels from the past 5 days, onto just the current day@halcyonguy
Hey, I apologize for bumping an old thread and pinging you here, but I was wondering if you ever got around to figuring out OP/your own study? I too am doing something similar to OP's original query - basically wanting to plot levels of significance (high, low, POCs of day bars) dating back from two Sundays ago to current. For example, if today is Monday (8/23), then ideally, the study would be plotting levels up to the second previous Sunday (8/15) on today's chart. However, I'm not quite sure how to even approach this. I started by trying to define the Sunday as an offset to input in the look back of the variable, but quickly learned thats not how it worked. A friend of mine, though not familiar with thinkscript, told me that a fold function might work. I looked into this on ToS' TLC website and from what I can tell, if I define the days as numbers with Sunday being the start, it could loop until the 14th day? I'm not even sure if that makes sense.
If possible, any help and/or advice here is greatly appreciated. Again, sorry to ping and bump this old thread.
Couch.
Code:
# prev5dayslevels_01
# get hi low levels from prev 5 days
# display lines on current day
def na = Double.NaN;
def istoday = if GetLastDay() == GetDay() then 1 else 0;
input timeFrame = AggregationPeriod.DAY;
def hi1 = high(period = timeFrame)[1];
def lo1 = low(period = timeFrame)[1];
def hi2 = high(period = timeFrame)[2];
def lo2 = low(period = timeFrame)[2];
def hi3 = high(period = timeFrame)[3];
def lo3 = low(period = timeFrame)[3];
def hi4 = high(period = timeFrame)[4];
def lo4 = low(period = timeFrame)[4];
def hi5 = high(period = timeFrame)[5];
def lo5 = low(period = timeFrame)[5];
plot hh1 = if istoday then hi1 else na;
plot ll1 = if istoday then lo1 else na;
plot hh2 = if istoday then hi2 else na;
plot ll2 = if istoday then lo2 else na;
plot hh3 = if istoday then hi3 else na;
plot ll3 = if istoday then lo3 else na;
plot hh4 = if istoday then hi4 else na;
plot ll4 = if istoday then lo4 else na;
plot hh5 = if istoday then hi5 else na;
plot ll5 = if istoday then lo5 else na;
hh1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ll1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hh2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ll2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hh3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ll3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hh4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ll4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hh5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ll5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hh1.SetDefaultColor(Color.light_green);
ll1.SetDefaultColor(Color.light_red);
hh2.SetDefaultColor(Color.light_green);
ll2.SetDefaultColor(Color.light_red);
hh3.SetDefaultColor(Color.light_green);
ll3.SetDefaultColor(Color.light_red);
hh4.SetDefaultColor(Color.light_green);
ll4.SetDefaultColor(Color.light_red);
hh5.SetDefaultColor(Color.light_green);
ll5.SetDefaultColor(Color.light_red);
#