Here is a slight modification that draws a rectangle automatically of the previous days high and lows showing that range. Also currently plots dotted line for today's high/low/open. Also has labels that will show green if above, red if below, and yellow if in-between.
https://tos.mx/!kuZiUvIn
https://tos.mx/!kuZiUvIn
Code:
# Previous Day + Today High/Low/Open with Cloud
declare hide_on_daily;
input show_labels = yes;
input length = 1;
input showOnlyLastPeriod = yes;
input ShowBubbles = yes;
input locate_bubbles_at = {default Expansion, Time};
input locate_bubbles_at_time = 800;
input BarsFromExpansion = 8;
input ShowPricesInBubbles = yes;
input showPrevDayCloud = yes;
input cloudTransparency = 60; # 0 is solid, 100 is invisible
def na = Double.NaN;
def aggregationPeriod = AggregationPeriod.DAY;
def displace = -1;
def timeopen = SecondsFromTime(locate_bubbles_at_time) == 0;
def isExpansion = locate_bubbles_at == locate_bubbles_at.Expansion and IsNaN(close);
def firstExpansionBar = if !IsNaN(close[-1]) and isExpansion then 1 else if isExpansion then firstExpansionBar[1] + 1 else 0;
def BubbleLocation = if locate_bubbles_at == locate_bubbles_at.Time then timeopen else isExpansion and firstExpansionBar == BarsFromExpansion;
#----- Previous Day High/Low/Close -----#
plot PD_High;
plot PD_Low;
plot PD_Close;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
PD_High = na;
PD_Low = na;
PD_Close = na;
} else {
PD_High = Highest(high(period = aggregationPeriod)[-displace], length);
PD_Low = Lowest(low(period = aggregationPeriod)[-displace], length);
PD_Close = close(period = aggregationPeriod)[-displace];
}
#----- Today's High/Low/Open -----#
def today = GetDay() == GetLastDay();
def newDay = GetDay() != GetDay()[1];
def intradayHigh = if newDay then high else if high > intradayHigh[1] then high else intradayHigh[1];
def intradayLow = if newDay then low else if low < intradayLow[1] then low else intradayLow[1];
def intradayOpen = if newDay then open else intradayOpen[1];
plot Today_High = if today then intradayHigh else na;
plot Today_Low = if today then intradayLow else na;
plot Today_Open = if today then intradayOpen else na;
# Clouds
AddCloud(
if showPrevDayCloud and !IsNaN(close) then PD_High else na,
if showPrevDayCloud and !IsNaN(close) then PD_Low else na,
Color.LIGHT_GRAY,
Color.LIGHT_GRAY
);
# Line styles and colors
PD_High.SetDefaultColor(Color.DARK_ORANGE);
PD_High.SetStyle(Curve.LONG_DASH);
PD_High.SetLineWeight(1);
PD_High.HideTitle();
PD_Low.SetDefaultColor(Color.DARK_ORANGE);
PD_Low.SetStyle(Curve.LONG_DASH);
PD_Low.SetLineWeight(1);
PD_Low.HideTitle();
PD_Close.SetDefaultColor(Color.WHITE);
PD_Close.SetStyle(Curve.LONG_DASH);
PD_Close.SetLineWeight(1);
PD_Close.AssignValueColor(if close > PD_Close then Color.GREEN else Color.RED);
PD_Close.HideTitle();
Today_High.SetDefaultColor(Color.CYAN);
Today_High.SetStyle(Curve.SHORT_DASH);
Today_High.SetLineWeight(1);
Today_High.HideTitle();
Today_Low.SetDefaultColor(Color.CYAN);
Today_Low.SetStyle(Curve.SHORT_DASH);
Today_Low.SetLineWeight(1);
Today_Low.HideTitle();
Today_Open.SetDefaultColor(Color.CYAN);
Today_Open.SetStyle(Curve.SHORT_DASH);
Today_Open.SetLineWeight(1);
Today_Open.HideTitle();
# Chart Bubbles
DefineGlobalColor("PD_High", CreateColor(255, 204, 153));
DefineGlobalColor("PD_Low", CreateColor(255, 204, 153));
DefineGlobalColor("PD_Close", Color.WHITE);
DefineGlobalColor("Today_High", Color.CYAN);
DefineGlobalColor("Today_Low", Color.CYAN);
DefineGlobalColor("Today_Open", Color.CYAN);
AddChartBubble(ShowBubbles and BubbleLocation, PD_High, "PDH: " + (if ShowPricesInBubbles then AsText(PD_High) else ""), GlobalColor("PD_High"));
AddChartBubble(ShowBubbles and BubbleLocation, PD_Low, "PDL: " + (if ShowPricesInBubbles then AsText(PD_Low) else ""), GlobalColor("PD_Low"), no);
AddChartBubble(ShowBubbles and BubbleLocation, PD_Close, "PDC: " + (if ShowPricesInBubbles then AsText(PD_Close) else ""), GlobalColor("PD_Close"));
AddChartBubble(ShowBubbles and BubbleLocation, Today_High, "HOD: " + (if ShowPricesInBubbles then AsText(Today_High) else ""), GlobalColor("Today_High"));
AddChartBubble(ShowBubbles and BubbleLocation, Today_Low, "LOD: " + (if ShowPricesInBubbles then AsText(Today_Low) else ""), GlobalColor("Today_Low"), no);
AddChartBubble(ShowBubbles and BubbleLocation, Today_Open, "TODAY OPEN: " + (if ShowPricesInBubbles then AsText(Today_Open) else ""), GlobalColor("Today_Open"));
# Labels
def abovePrevHigh = close > PD_High;
def belowPrevLow = close < PD_Low;
def withinPrevRange = close <= PD_High and close >= PD_Low;
AddLabel(show_labels and abovePrevHigh, "PDH", Color.GREEN);
AddLabel(show_labels and belowPrevLow, "PDL", Color.RED);
AddLabel(show_labels and withinPrevRange, "INSIDE PDH/PDL", Color.YELLOW);
AddLabel(show_labels, "PDC", if close > PD_Close then Color.GREEN else Color.RED);
#AddLabel(show_labels, "HOD", Color.CYAN);
#AddLabel(show_labels, "LOD", Color.CYAN);
#AddLabel(show_labels, "Open", Color.CYAN);