High / Low Lines, Scans, Watchlists, Code For ThinkOrSwim

desirobinhood

New member
Indicator to show previous day High Low and Close on the current day chart

Rich (BB code):
input aggregationPeriod = AggregationPeriod.DAY;
input length = 1;
input displace = -1;
input showOnlyLastPeriod = yes;
plot PrevDayHigh;
plot PrevDayLow;
plot PrevDayClose;

if showOnlyLastPeriod and !IsNaN(high(period = aggregationPeriod)[-1]) and !IsNaN(low(period = aggregationPeriod)[-1]) and !IsNaN(close(period = aggregationPeriod)[-1])
{
    PrevDayHigh = Double.NaN;
    PrevDayLow = Double.NaN;
    PrevDayClose = Double.NaN;
}
else
{
    PrevDayHigh = Highest(high(period = aggregationPeriod)[-displace], length);
    PrevDayLow = Highest(low(period = aggregationPeriod)[-displace], length);
    PrevDayClose = Highest(close(period = aggregationPeriod)[-displace], length);
}
PrevDayHigh.SetDefaultColor(CreateColor(0,255,255));
PrevDayHigh.SetPaintingStrategy(PaintingStrategy.LINE);

PrevDayLow.SetDefaultColor(CreateColor(0,255,255));
PrevDayLow.SetPaintingStrategy(PaintingStrategy.LINE);

PrevDayClose.SetDefaultColor(CreateColor(116,189,239));
PrevDayClose.SetPaintingStrategy(PaintingStrategy.LINE);
PrevDayClose.SetStyle(Curve.LONG_DASH)
 
makes sense for lower timeframes than 1D.

Ruby:
def ap = AggregationPeriod.DAY;

def dH = High(period = ap);
def dL = Low(period = ap);

plot DayHigh = dH;
plot DayLow =dL;

DayHigh.SetDefaultColor(Color.PINK);
DayLow.SetDefaultColor(Color.CYAN);
 
Here we go, horizontal line at HOD, use this on an intraday chart

Code:
plot highLine = highestAll(if isNaN(close[-1])
                            then high(period = "Day")
                            else Double.NaN);
Hi Tomsk,
I have always liked highs and lows for both the day and the week. Would it be possible to terminate the lines at the beginning and end of the day and week. I am basically a S/R visual trader and I like to look at extended periods of days and weeks to see how whatever stock or future respects these natural S/R areas. I was surprised that the code was as simple as it was. BTW, I just changed your code to add a Lowline and changed the day to week. I am really pleased I found this.
SteveS
 
Hi Tomsk,
I have always liked highs and lows for both the day and the week. Would it be possible to terminate the lines at the beginning and end of the day and week. I am basically a S/R visual trader and I like to look at extended periods of days and weeks to see how whatever stock or future respects these natural S/R areas. I was surprised that the code was as simple as it was. BTW, I just changed your code to add a Lowline and changed the day to week. I am really pleased I found this.
SteveS
Try this
Capture.jpg
Ruby:
plot day_high = high(period = AggregationPeriod.DAY);
plot day_low  = low(period = AggregationPeriod.DAY);
day_high.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
day_low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot week_high = high(period = AggregationPeriod.WEEK);
plot week_low  = low(period = AggregationPeriod.WEEK);
week_high.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
week_low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
 
Hi Tomsk,
I have always liked highs and lows for both the day and the week. Would it be possible to terminate the lines at the beginning and end of the day and week. I am basically a S/R visual trader and I like to look at extended periods of days and weeks to see how whatever stock or future respects these natural S/R areas. I was surprised that the code was as simple as it was. BTW, I just changed your code to add a Lowline and changed the day to week. I am really pleased I found this.
SteveS
Hello again,
Would it be possible to NOT extend left when new H/L has been hit. Being the visual trader that I am, I find I have too much to take in. Here is what I have.

plot Day_high = high(period = AggregationPeriod.DAY);
plot Day_low = low(period = AggregationPeriod.DAY);
day_high.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
day_low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot Week_high = high(period = AggregationPeriod.WEEK);
plot Week_low = low(period = AggregationPeriod.WEEK);
week_high.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
week_low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot Month_high = high(period = AggregationPeriod.month);
plot Month_low = low(period = AggregationPeriod.month);
Month_high.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Month_low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot Quarter_high = high(period = AggregationPeriod.Quarter);
plot Quarter_low = low(period = AggregationPeriod.Quarter);
Quarter_high.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Quarter_low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
 
Hello again,
Would it be possible to NOT extend left when new H/L has been hit. Being the visual trader that I am, I find I have too much to take in. Here is what I have.

plot Day_high = high(period = AggregationPeriod.DAY);
plot Day_low = low(period = AggregationPeriod.DAY);
day_high.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
day_low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot Week_high = high(period = AggregationPeriod.WEEK);
plot Week_low = low(period = AggregationPeriod.WEEK);
week_high.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
week_low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot Month_high = high(period = AggregationPeriod.month);
plot Month_low = low(period = AggregationPeriod.month);
Month_high.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Month_low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot Quarter_high = high(period = AggregationPeriod.Quarter);
plot Quarter_low = low(period = AggregationPeriod.Quarter);
Quarter_high.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Quarter_low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

Added showlastonly input. In the picture, since we are at the beginning of November that began on a Monday, the month and week overlap, making a little difficult to test the code.

Capture.jpg
Ruby:
input showlastonly = yes;
plot Day_high = if showlastonly and !IsNaN(high(period = AggregationPeriod.DAY)[-1]) then Double.NaN else high(period = AggregationPeriod.DAY);
plot Day_low = if showlastonly and !IsNaN(low(period = AggregationPeriod.DAY)[-1]) then Double.NaN else low(period = AggregationPeriod.DAY);
Day_high.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Day_low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot Week_high = if showlastonly and !IsNaN(high(period = AggregationPeriod.WEEK)[-1]) then Double.NaN else high(period = AggregationPeriod.WEEK);
plot Week_low = if showlastonly and !IsNaN(low(period = AggregationPeriod.WEEK)[-1]) then Double.NaN else low(period = AggregationPeriod.WEEK);
Week_high.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Week_low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot Month_high = if showlastonly and !IsNaN(high(period = AggregationPeriod.MONTH)[-1]) then Double.NaN else high(period = AggregationPeriod.MONTH);
plot Month_low = if showlastonly and !IsNaN(low(period = AggregationPeriod.MONTH)[-1]) then Double.NaN else low(period = AggregationPeriod.MONTH);
Month_high.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Month_low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot Quarter_high = if showlastonly and !IsNaN(high(period = AggregationPeriod.QUARTER)[-1]) then Double.NaN else high(period = AggregationPeriod.QUARTER);
plot Quarter_low = if showlastonly and !IsNaN(low(period = AggregationPeriod.QUARTER)[-1]) then Double.NaN else low(period = AggregationPeriod.QUARTER);
Quarter_high.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Quarter_low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
 
So now, I have an indicator that shows the H/L for day,week,month and quarter.
I am a visual trader and like to see how each period...In my mind, it frames price for me.
The problem with the indicator, is: when it shows a high, it does not show just from the high made, it shows the entire period.

For instance, if a high is made on a Wednesday on a weekly, the line will extend from Monday until Friday when I want to see just from Wednesday to the end of the week. This also applies to day, month, and quarter.
Anyway, here is what I have.

input showlastonly = yes;
plot Day_high = if showlastonly and !IsNaN(high(period = AggregationPeriod.DAY)[-1]) then Double.NaN else high(period = AggregationPeriod.DAY);
plot Day_low = if showlastonly and !IsNaN(low(period = AggregationPeriod.DAY)[-1]) then Double.NaN else low(period = AggregationPeriod.DAY);
Day_high.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Day_low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot Week_high = if showlastonly and !IsNaN(high(period = AggregationPeriod.WEEK)[-1]) then Double.NaN else high(period = AggregationPeriod.WEEK);
plot Week_low = if showlastonly and !IsNaN(low(period = AggregationPeriod.WEEK)[-1]) then Double.NaN else low(period = AggregationPeriod.WEEK);
Week_high.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Week_low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot Month_high = if showlastonly and !IsNaN(high(period = AggregationPeriod.MONTH)[-1]) then Double.NaN else high(period = AggregationPeriod.MONTH);
plot Month_low = if showlastonly and !IsNaN(low(period = AggregationPeriod.MONTH)[-1]) then Double.NaN else low(period = AggregationPeriod.MONTH);
Month_high.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Month_low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot Quarter_high = if showlastonly and !IsNaN(high(period = AggregationPeriod.QUARTER)[-1]) then Double.NaN else high(period = AggregationPeriod.QUARTER);
plot Quarter_low = if showlastonly and !IsNaN(low(period = AggregationPeriod.QUARTER)[-1]) then Double.NaN else low(period = AggregationPeriod.QUARTER);
Quarter_high.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Quarter_low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
 
Last edited by a moderator:
So now, I have an indicator that shows the H/L for day,week,month and quarter.
I am a visual trader and like to see how each period...In my mind, it frames price for me.
The problem with the indicator, is: when it shows a high, it does not show just from the high made, it shows the entire period.

For instance, if a high is made on a Wednesday on a weekly, the line will extend from Monday until Friday when I want to see just from Wednesday to the end of the week. This also applies to day, month, and quarter.
Anyway, here is what I have.

input showlastonly = yes;
plot Day_high = if showlastonly and !IsNaN(high(period = AggregationPeriod.DAY)[-1]) then Double.NaN else high(period = AggregationPeriod.DAY);
plot Day_low = if showlastonly and !IsNaN(low(period = AggregationPeriod.DAY)[-1]) then Double.NaN else low(period = AggregationPeriod.DAY);
Day_high.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Day_low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot Week_high = if showlastonly and !IsNaN(high(period = AggregationPeriod.WEEK)[-1]) then Double.NaN else high(period = AggregationPeriod.WEEK);
plot Week_low = if showlastonly and !IsNaN(low(period = AggregationPeriod.WEEK)[-1]) then Double.NaN else low(period = AggregationPeriod.WEEK);
Week_high.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Week_low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot Month_high = if showlastonly and !IsNaN(high(period = AggregationPeriod.MONTH)[-1]) then Double.NaN else high(period = AggregationPeriod.MONTH);
plot Month_low = if showlastonly and !IsNaN(low(period = AggregationPeriod.MONTH)[-1]) then Double.NaN else low(period = AggregationPeriod.MONTH);
Month_high.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Month_low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot Quarter_high = if showlastonly and !IsNaN(high(period = AggregationPeriod.QUARTER)[-1]) then Double.NaN else high(period = AggregationPeriod.QUARTER);
plot Quarter_low = if showlastonly and !IsNaN(low(period = AggregationPeriod.QUARTER)[-1]) then Double.NaN else low(period = AggregationPeriod.QUARTER);
Quarter_high.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Quarter_low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

See if this helps.

Capture.jpg
Ruby:
def bn      = BarNumber();
def nan     = Double.NaN;

def hqb    = HighestAll(if high == high(period = AggregationPeriod.QUARTER) then bn else nan);
def hqh    = if bn == hqb then high else hqh[1];
plot highq = if bn < hqb then nan else hqh;
highq.setdefaultColor(color.yellow);

def hmb    = HighestAll(if high == high(period = AggregationPeriod.MONTH) then bn else nan);
def hmh    = if bn == hmb then high else hmh[1];
plot highm = if bn < hmb then nan else hmh;
highm.setdefaultColor(color.white);

def hwb    = HighestAll(if high == high(period = AggregationPeriod.WEEK) then bn else nan);
def hwh    = if bn == hwb then high else hwh[1];
plot highw = if bn < hwb then nan else hwh;
highw.setdefaultColor(color.magenta);

def hdb    = highestall(if high == high(period=aggregationPeriod.DAY) then bn else nan);
def hdh    = if bn == hdb then high else hdh[1];
plot highd = if bn < hdb then nan else hdh;
highd.setdefaultColor(color.cyan);

def lqb   = HighestAll(if low == low(period = AggregationPeriod.QUARTER) then bn else nan);
def lql   = if bn == lqb then low else lql[1];
plot lowq = if bn < lqb then nan else lql;
lowq.setdefaultColor(color.yellow);

def lmb   = HighestAll(if low == low(period = AggregationPeriod.MONTH) then bn else nan);
def lml   = if bn == lmb then low else lml[1];
plot lowm = if bn < lmb then nan else lml;
lowm.setdefaultColor(color.white);

def lwb   = HighestAll(if low == low(period = AggregationPeriod.WEEK) then bn else nan);
def lwl   = if bn == lwb then low else lwl[1];
plot loww = if bn < lwb then nan else lwl;
loww.setdefaultColor(color.magenta);

def ldb   = HighestAll(if low == low(period = AggregationPeriod.DAY) then bn else nan);
def ldl   = if bn == ldb then low else ldl[1];
plot lowd = if bn < ldb then nan else ldl;
lowd.setdefaultColor(color.cyan);

input showbubbles = yes;
input bubblemover = 4;
def b = bubblemover;
def b1 = b + 1;

AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), hqh[b], "QH", highq.takevalueColor());
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), hmh[b], "MH", highm.takevalueColor());
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), hwh[b], "WH", highw.takevalueColor());
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), hdh[b], "DH", highd.takevalueColor());

AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), lql[b], "QL", lowq.takevalueColor(), no);
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), lml[b], "ML", lowm.takevalueColor(), no);
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), lwl[b], "WL", loww.takevalueColor(), no);
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), ldl[b], "DL", lowd.takevalueColor(), no);

input debug = no;
AddLabel(debug, hdb + " " + hqh + " " + hmh + " " + hwh + " " + hdh);
AddLabel(debug, lqb + " " + lql + " " + lml + " " + lwl + " " + ldl);
plot bar = if !debug then nan else bn;
bar.setpaintingStrategy(paintingStrategy.VALUES_BELOW);
 
See if this helps.
Hello SleepyZ,

This is awesome which helps me to visualize the chart more efficiently. Also, I have a couple of requests to add to the existing code.

1. Can you update the display to show the lines for the aggregation period? Say Weekly, monthly or quarterly. If I switch the chart to weekly or monthly, it doesn't display the lines.
2. I need another line that displays the 50% for the day, week, month, and quarter.

Appreciate your help.

Thanks
Jay
 
Hello SleepyZ,

This is awesome which helps me to visualize the chart more efficiently. Also, I have a couple of requests to add to the existing code.

1. Can you update the display to show the lines for the aggregation period? Say Weekly, monthly or quarterly. If I switch the chart to weekly or monthly, it doesn't display the lines.
2. I need another line that displays the 50% for the day, week, month, and quarter.

Appreciate your help.

Thanks
Jay

Jay,
1. If a script contains aggregation periods lower than the chart aggregation, then nothing will be displayed. Below are separate scripts to be saved. Each will display on the charts with the aggregations shown for each script.
2. Added to all the scripts below.

Daily and below chart aggregations
Ruby:
def bn      = BarNumber();
def nan     = Double.NaN;

def hqb    = HighestAll(if high == high(period = AggregationPeriod.QUARTER) then bn else nan);
def hqh    = if bn == hqb then high else hqh[1];
plot highq = if bn < hqb then nan else hqh;
highq.setdefaultColor(color.yellow);

def hmb    = HighestAll(if high == high(period = AggregationPeriod.MONTH) then bn else nan);
def hmh    = if bn == hmb then high else hmh[1];
plot highm = if bn < hmb then nan else hmh;
highm.setdefaultColor(color.white);

def hwb    = HighestAll(if high == high(period = AggregationPeriod.WEEK) then bn else nan);
def hwh    = if bn == hwb then high else hwh[1];
plot highw = if bn < hwb then nan else hwh;
highw.setdefaultColor(color.magenta);

def hdb    = highestall(if high == high(period=aggregationPeriod.DAY) then bn else nan);
def hdh    = if bn == hdb then high else hdh[1];
plot highd = if bn < hdb then nan else hdh;
highd.setdefaultColor(color.cyan);

def lqb   = HighestAll(if low == low(period = AggregationPeriod.QUARTER) then bn else nan);
def lql   = if bn == lqb then low else lql[1];
plot lowq = if bn < lqb then nan else lql;
lowq.setdefaultColor(color.yellow);

def lmb   = HighestAll(if low == low(period = AggregationPeriod.MONTH) then bn else nan);
def lml   = if bn == lmb then low else lml[1];
plot lowm = if bn < lmb then nan else lml;
lowm.setdefaultColor(color.white);

def lwb   = HighestAll(if low == low(period = AggregationPeriod.WEEK) then bn else nan);
def lwl   = if bn == lwb then low else lwl[1];
plot loww = if bn < lwb then nan else lwl;
loww.setdefaultColor(color.magenta);

def ldb   = HighestAll(if low == low(period = AggregationPeriod.DAY) then bn else nan);
def ldl   = if bn == ldb then low else ldl[1];
plot lowd = if bn < ldb then nan else ldl;
lowd.setdefaultColor(color.cyan);

plot hl2q    = (highq + lowq) /2;
hl2q.setdefaultColor(color.yellow);

plot hl2m    = (highm + lowm) /2;
hl2m.setdefaultColor(color.white);

plot hl2w    = (highw + loww) /2;
hl2w.setdefaultColor(color.magenta);

plot hl2d    = (highd + lowd) /2;
hl2d.setdefaultColor(color.cyan);

input showbubbles = yes;
input bubblemover = 4;
def b = bubblemover;
def b1 = b + 1;

AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), hqh[b], "QH", highq.takevalueColor());
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), hmh[b], "MH", highm.takevalueColor());
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), hwh[b], "WH", highw.takevalueColor());
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), hdh[b], "DH", highd.takevalueColor());

AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), lql[b], "QL", lowq.takevalueColor(), no);
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), lml[b], "ML", lowm.takevalueColor(), no);
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), lwl[b], "WL", loww.takevalueColor(), no);
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), ldl[b], "DL", lowd.takevalueColor(), no);

AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), hl2q[b], "QHL2", hl2q.takevalueColor());
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), hl2m[b], "MHL2", hl2m.takevalueColor());
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), hl2w[b], "WHL2", hl2w.takevalueColor());
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), hl2d[b], "DHL2", hl2d.takevalueColor());

input debug = no;
AddLabel(debug, hdb + " " + hqh + " " + hmh + " " + hwh + " " + hdh);
AddLabel(debug, lqb + " " + lql + " " + lml + " " + lwl + " " + ldl);
plot bar = if !debug then nan else bn;
bar.setpaintingStrategy(paintingStrategy.VALUES_BELOW);

Weekly and below chart aggregations
Ruby:
def bn      = BarNumber();
def nan     = Double.NaN;

def hqb    = HighestAll(if high == high(period = AggregationPeriod.QUARTER) then bn else nan);
def hqh    = if bn == hqb then high else hqh[1];
plot highq = if bn < hqb then nan else hqh;
highq.setdefaultColor(color.yellow);

def hmb    = HighestAll(if high == high(period = AggregationPeriod.MONTH) then bn else nan);
def hmh    = if bn == hmb then high else hmh[1];
plot highm = if bn < hmb then nan else hmh;
highm.setdefaultColor(color.white);

def hwb    = HighestAll(if high == high(period = AggregationPeriod.WEEK) then bn else nan);
def hwh    = if bn == hwb then high else hwh[1];
plot highw = if bn < hwb then nan else hwh;
highw.setdefaultColor(color.magenta);

def lqb   = HighestAll(if low == low(period = AggregationPeriod.QUARTER) then bn else nan);
def lql   = if bn == lqb then low else lql[1];
plot lowq = if bn < lqb then nan else lql;
lowq.setdefaultColor(color.yellow);

def lmb   = HighestAll(if low == low(period = AggregationPeriod.MONTH) then bn else nan);
def lml   = if bn == lmb then low else lml[1];
plot lowm = if bn < lmb then nan else lml;
lowm.setdefaultColor(color.white);

def lwb   = HighestAll(if low == low(period = AggregationPeriod.WEEK) then bn else nan);
def lwl   = if bn == lwb then low else lwl[1];
plot loww = if bn < lwb then nan else lwl;
loww.setdefaultColor(color.magenta);

plot hl2q    = (highq + lowq) /2;
hl2q.setdefaultColor(color.yellow);

plot hl2m    = (highm + lowm) /2;
hl2m.setdefaultColor(color.white);

plot hl2w    = (highw + loww) /2;
hl2w.setdefaultColor(color.magenta);

input showbubbles = yes;
input bubblemover = 4;
def b = bubblemover;
def b1 = b + 1;

AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), hqh[b], "QH", highq.takevalueColor());
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), hmh[b], "MH", highm.takevalueColor());
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), hwh[b], "WH", highw.takevalueColor());

AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), lql[b], "QL", lowq.takevalueColor(), no);
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), lml[b], "ML", lowm.takevalueColor(), no);
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), lwl[b], "WL", loww.takevalueColor(), no);

AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), hl2q[b], "QHL2", hl2q.takevalueColor());
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), hl2m[b], "MHL2", hl2m.takevalueColor());
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), hl2w[b], "WHL2", hl2w.takevalueColor());

Montly and below chart aggregations

Ruby:
def bn      = BarNumber();
def nan     = Double.NaN;

def hqb    = HighestAll(if high == high(period = AggregationPeriod.QUARTER) then bn else nan);
def hqh    = if bn == hqb then high else hqh[1];
plot highq = if bn < hqb then nan else hqh;
highq.setdefaultColor(color.yellow);

def hmb    = HighestAll(if high == high(period = AggregationPeriod.MONTH) then bn else nan);
def hmh    = if bn == hmb then high else hmh[1];
plot highm = if bn < hmb then nan else hmh;
highm.setdefaultColor(color.white);


def lqb   = HighestAll(if low == low(period = AggregationPeriod.QUARTER) then bn else nan);
def lql   = if bn == lqb then low else lql[1];
plot lowq = if bn < lqb then nan else lql;
lowq.setdefaultColor(color.yellow);

def lmb   = HighestAll(if low == low(period = AggregationPeriod.MONTH) then bn else nan);
def lml   = if bn == lmb then low else lml[1];
plot lowm = if bn < lmb then nan else lml;
lowm.setdefaultColor(color.white);


plot hl2q    = (highq + lowq) /2;
hl2q.setdefaultColor(color.yellow);

plot hl2m    = (highm + lowm) /2;
hl2m.setdefaultColor(color.white);

input showbubbles = yes;
input bubblemover = 4;
def b = bubblemover;
def b1 = b + 1;

AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), hqh[b], "QH", highq.takevalueColor());
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), hmh[b], "MH", highm.takevalueColor());

AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), lql[b], "QL", lowq.takevalueColor(), no);
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), lml[b], "ML", lowm.takevalueColor(), no);

AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), hl2q[b], "QHL2", hl2q.takevalueColor());
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), hl2m[b], "MHL2", hl2m.takevalueColor());
 
Dr. Wish Green Line Breakout Indicator for ThinkOrSwim
the highest price reached at any month, that has not been surpassed for at least 3 months.

I was looking for help to develop a scan and possibly show up a line on the charts (daily timeframe preferably) for a simple trading methodology given in the below post:
https://wishingwealthblog.com/2018/05/green-line-breakout-glb-explained-gmi-remains-green/

Strategy:
I begin by looking at a monthly chart for each stock that hit a new all time high recently and draw a green horizontal line at the highest price reached at any month, that has not been surpassed for at least 3 months. In other words, I want a stock that reached an all-time high and has then rested for at least three months. When a stock moves through the green line or is above its last green line I become interested. I only buy stocks that are trading above their last green line tops. Stocks that form a multi-month (or multi-year) base at an all time high, especially recent IPOs, often go on to large gains after they break out. (The great Jesse Livermore made a similar observation.)

This simple yet powerful strategy can be used by investors who have a full time job and can't spend whole day in front of the trading screen.

Appreciate if someone can help with a scan and a line plot on the chart.

thanks in advance!
 
Last edited by a moderator:
Dr. Wish Green Line Breakout Indicator for ThinkOrSwim
the highest price reached at any month, that has not been surpassed for at least 3 months.

I was looking for help to develop a scan and possibly show up a line on the charts (daily timeframe preferably) for a simple trading methodology given in the below post:
https://wishingwealthblog.com/2018/05/green-line-breakout-glb-explained-gmi-remains-green/

Strategy:
I begin by looking at a monthly chart for each stock that hit a new all time high recently and draw a green horizontal line at the highest price reached at any month, that has not been surpassed for at least 3 months. In other words, I want a stock that reached an all-time high and has then rested for at least three months. When a stock moves through the green line or is above its last green line I become interested. I only buy stocks that are trading above their last green line tops. Stocks that form a multi-month (or multi-year) base at an all time high, especially recent IPOs, often go on to large gains after they break out. (The great Jesse Livermore made a similar observation.)

This simple yet powerful strategy can be used by investors who have a full time job and can't spend whole day in front of the trading screen.

Appreciate if someone can help with a scan and a line plot on the chart.

thanks in advance!
We don't have anything like that currently on the forum
 
Hello my coder friends,

I have a small request. The Day High Low indicator in ToS is a very good tool for quickly finding highs and lows of candles on different time frames. I would like to have a version of this script that puts a horizontal line at the top and bottom of the candle, AND, also at the 50% level of that same candle. I would also like for these horizontal lines to just extend to the right side of the screen, and eliminate the future levels that begin to form with the current candle. I'm only interested in the previous candle levels. Or make it optional so I can deselect it.

I tried doing this with Fibs but I have draw them in every chart and the extra manual work just ****s.

Any help on this would be great.

Thank you!
Charlie
 
Hello my coder friends,

I have a small request. The Day High Low indicator in ToS is a very good tool for quickly finding highs and lows of candles on different time frames. I would like to have a version of this script that puts a horizontal line at the top and bottom of the candle, AND, also at the 50% level of that same candle. I would also like for these horizontal lines to just extend to the right side of the screen, and eliminate the future levels that begin to form with the current candle. I'm only interested in the previous candle levels. Or make it optional so I can deselect it.

I tried doing this with Fibs but I have draw them in every chart and the extra manual work just ****s.

Any help on this would be great.

Thank you!
Charlie
I moved your post here. Perhaps you can make do with one of the scripts here.
 
Happy holidays to all, looking for some assistance in calculating and plotting the high/low for a custom time range. I have the following code configured to draw vertical lines for a specified start and end time:

Ruby:
input startingHour = 0930;
def endingHour = startingHour - 15;

def RB = secondsFromTime(startingHour)[1] < 0 && secondsFromTime(startingHour) >= 0;
def RE = secondsFromTime(endingHour)[1] < 0 && secondsFromTime(endingHour) >= 0;

AddVerticalLine(RB, concat("Start: ", startingHour), Color.Green, curve.POINTS);
AddVerticalLine(RE, concat("End: ", endingHour), Color.Red, curve.POINTS);

I'd like to be able to find the high/low for each session and plot those horizontal lines on the following session:

es_custom-session_high-low_20211225.png


Hope that makes sense, any assistance would be greatly appreciated.

Thanks!
 
Happy holidays to all, looking for some assistance in calculating and plotting the high/low for a custom time range. I have the following code configured to draw vertical lines for a specified start and end time:

Ruby:
input startingHour = 0930;
def endingHour = startingHour - 15;

def RB = secondsFromTime(startingHour)[1] < 0 && secondsFromTime(startingHour) >= 0;
def RE = secondsFromTime(endingHour)[1] < 0 && secondsFromTime(endingHour) >= 0;

AddVerticalLine(RB, concat("Start: ", startingHour), Color.Green, curve.POINTS);
AddVerticalLine(RE, concat("End: ", endingHour), Color.Red, curve.POINTS);

I'd like to be able to find the high/low for each session and plot those horizontal lines on the following session:

es_custom-session_high-low_20211225.png


Hope that makes sense, any assistance would be greatly appreciated.

Thanks!
See if this is helps do what you wanted
Capture.jpg
Ruby:
input startingHour = 0930;
def endingHour = startingHour - 15;

def RB    = secondsFromTime(startingHour)[1] < 0 && secondsFromTime(startingHour) >= 0;
def RE    = secondsFromTime(endingHour)[1] < 0 && secondsFromTime(endingHour) >= 0;
def range = secondsfromTime(endinghour)>=0 and secondstillTime(startinghour)>0;

AddVerticalLine(RB, concat("Start: ", startingHour), Color.Green, curve.POINTS);
AddVerticalLine(RE, concat("End: ", endingHour), Color.Red, curve.POINTS);

def h    = if Re then high else if range and high > h[1] then high else h[1];
plot rbh = h;
rbh.setpaintingStrategy(paintingStrategy.HORIZONTAL);
def l    = if Re then low else if range and low < l[1] then low else l[1];
plot rbl = l;
rbl.setpaintingStrategy(paintingStrategy.HORIZONTAL);
 
See if this is helps do what you wanted
@SleepyZ - Yes, that is perfect, thanks!

After I posted I realized that the way I had it coded originally set the end time before the start time (duh), but once properly configured with an intraday range it functions as expected. I'm working on a version that can span more than one day, I'll post it here when (if) I figure it out. :unsure:

Thanks again!
 
Last edited:
Hello,

How do you create a script that would draw a horizontal line at the High and Low of the first previous candle only?

For example like this image:

r6DUwt8.png
 
Last edited:
Hello,

How do you create a script that would draw a horizontal line at the High and Low of the first previous candle only?

For example like this image:

r6DUwt8.png

Below is a modication of a script that posted elsewhere. You can input offset to lookback to whatever candle high/low/close you want that will display on the last bar of your chart horizontal lines and chart bubbles, as well as, a label at the top of the chart.

Ruby:
input offset  = 1;

def lasthigh  = if IsNaN(close[-1]) and !IsNaN(close) then high[offset] else lasthigh[1];
def lastclose = if IsNaN(close[-1]) and !IsNaN(close) then close[offset] else lastclose[1];
def lastlow   = if IsNaN(close[-1]) and !IsNaN(close) then low[offset]  else lastlow[1];

input showlines = yes;
plot lhigh   = if !showlines then double.nan else lasthigh;
plot lclose  = if !showlines then double.nan else  lastclose;
plot llow    = if !showlines then double.nan else  lastlow;
lhigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lclose.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
llow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

lhigh.SetDefaultColor(Color.GREEN);
lclose.SetDefaultColor(Color.YELLOW);
llow.SetDefaultColor(Color.RED);

input showlabels = yes;
AddLabel(showlabels, "High Bar: " + AsText(lasthigh), Color.green);
addlabel(showlabels, "Close Bar: " + astext(lastclose), color.yellow);
AddLabel(showlabels, "Low Bar: " + AsText(lastlow), Color.RED);

input showbubbles = yes;
input bubblemover = 3;
def   b = bubblemover;
def  b1 = b + 1;
def last = isnan(close[b]) and !isnan(close[b1]);
AddchartBubble(showbubbles and last, lhigh,  "High: " + AsText(lasthigh), Color.green);
addchartBubble(showbubbles and last, lclose, "Close: " + astext(lastclose), color.yellow);
AddchartBubble(showbubbles and last, llow,   "Low: " + AsText(lastlow), Color.RED);
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
303 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top