Previous Day High/Low/Close + Premarket High/Low + High/Low/Open of Day + ATR Lines for ThinkorSwim

Hi,

Can anyone help in adding Fib levels to following indicator below. Thank you!
@samer800 @chewie76
@SleepyZ

I would like fib levels with fib extension to be plotted.

1) Fib levels with fib extension from Pre Market Low to Pre Market High

2) Fib levels with fib extension from Pre Market high to Pre Market Low.

3) fib numbers plot as well as price on the line

# Previous Day High/Low/Close + Premarket High/Low + High/Low/Open of Day + ATR Lines
# Created by Wiinii
# V1.6
# Some code based on code by Mobius (premarket) and TraderKevin (ATR lines
# https://usethinkscript.com/threads/...w-high-low-open-of-day-for-thinkorswim.13139/

declare hide_on_daily;

input length = 1;
input showOnlyLastPeriod = yes;
input ShowBubbles = yes;
input locate_bubbles_at = {default Expansion, Time};
input locate_bubbles_at_time = 800;
input BarsFromExpansion = 1;
input ShowPricesInBubbles = yes;

def bn = BarNumber();
def na = Double.NaN;
def h = high;
def l = low;
def o = open;
def c = close;
def v = volume;
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];
}

PD_High.SetDefaultColor(Color.DARK_ORANGE);
PD_High.SetStyle(Curve.LONG_DASH);
PD_High.SetLineWeight(2);
PD_High.HideTitle();

PD_Low.SetDefaultColor(Color.DARK_ORANGE);
PD_Low.SetStyle(Curve.LONG_DASH);
PD_Low.SetLineWeight(2);
PD_Low.HideTitle();

PD_Close.SetDefaultColor(Color.WHITE);
PD_Close.SetStyle(Curve.LONG_DASH);
PD_Close.SetLineWeight(2);
PD_Close.HideTitle();

DefineGlobalColor("PD_High", CreateColor(255, 204, 153));
AddChartBubble(ShowBubbles and BubbleLocation, PD_High, "PDH: " + (if ShowPricesInBubbles then AsText(PD_High) else ""), GlobalColor("PD_High"));

DefineGlobalColor("PD_Low", CreateColor(255, 204, 153));
AddChartBubble(ShowBubbles and BubbleLocation, PD_Low, "PDL: " + (if ShowPricesInBubbles then AsText(PD_Low) else ""), GlobalColor("PD_Low"), no);

DefineGlobalColor("PD_Close", Color.WHITE);
AddChartBubble(ShowBubbles and BubbleLocation, PD_Close, "PDC: " + (if ShowPricesInBubbles then AsText(PD_Close) else ""), GlobalColor("PD_Close"));

PD_High.HideBubble();
PD_Low.HideBubble();
PD_Close.HideBubble();


#----- Premarket High/Low -----# Thanks to Mobius

def GlobeX = GetTime() < RegularTradingStart(GetYYYYMMDD());

def vol = if GlobeX and !GlobeX[1]
then v
else if GlobeX
then vol[1] + v
else na;

def GlobeX_Volume = vol;

def ONhigh = if GlobeX and !GlobeX[1]
then h
else if GlobeX and
h > ONhigh[1]
then h
else ONhigh[1];

def ONhighBar = if GlobeX and h == ONhigh
then bn
else na;

def ONlow = if GlobeX and !GlobeX[1]
then l
else if GlobeX and
l < ONlow[1]
then l
else ONlow[1];

def ONlowBar = if GlobeX and l == ONlow
then bn
else na;

def OverNightHigh = if BarNumber() == HighestAll(ONhighBar)
then ONhigh
else OverNightHigh[1];

def OverNightLow = if BarNumber() == HighestAll(ONlowBar)
then ONlow
else OverNightLow[1];

plot PM_High;
plot PM_Low;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
PM_High = na;
PM_Low = na;
} else {
PM_High = if OverNightHigh > 0 then OverNightHigh else na;
PM_Low = if OverNightLow > 0 then OverNightLow else na;
}

#PM_High.SetHiding(!PlotOverNightExtremes);
PM_High.SetLineWeight(2);
PM_High.SetDefaultColor(Color.CYAN);
PM_High.SetStyle(Curve.LONG_DASH);
PM_High.HideBubble();
PM_High.HideTitle();

#PM_Low.SetHiding(!PlotOverNightExtremes);
PM_Low.SetStyle(Curve.LONG_DASH);
PM_Low.SetDefaultColor(Color.CYAN);
PM_Low.HideBubble();
PM_Low.HideTitle();

DefineGlobalColor("PM_High", CreateColor(102, 255, 255));
AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONhighBar else isExpansion and firstExpansionBar == BarsFromExpansion, PM_High, "PMH: " + (if ShowPricesInBubbles then AsText(PM_High) else ""), GlobalColor("PM_High"));

DefineGlobalColor("PM_Low", CreateColor(102, 255, 255));
AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONlowBar else isExpansion and firstExpansionBar == BarsFromExpansion, PM_Low, "PML: " + (if ShowPricesInBubbles then AsText(PM_Low) else ""), GlobalColor("PM_Low"), no);


#----- Today Open/High/Low -----#


plot High_of_Day;
plot Low_of_Day;
plot DayOpen;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
DayOpen = na;
High_of_Day = na;
Low_of_Day = na;
} else {
DayOpen = open(period = aggregationPeriod)[0];
High_of_Day = Highest(high(period = aggregationPeriod), length);
Low_of_Day = Lowest(low(period = aggregationPeriod), length);
}

DayOpen.SetDefaultColor (Color.GRAY);
DayOpen.SetPaintingStrategy(PaintingStrategy.DASHES);
DayOpen.SetLineWeight(2);
DayOpen.HideTitle();

High_of_Day.SetDefaultColor(CreateColor(0, 128, 255));
High_of_Day.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
High_of_Day.SetLineWeight(2);
High_of_Day.HideTitle();

Low_of_Day.SetDefaultColor(CreateColor(0, 128, 255));
Low_of_Day.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Low_of_Day.SetLineWeight(2);
Low_of_Day.HideTitle();

DefineGlobalColor("Open", Color.LIGHT_GRAY);
AddChartBubble(ShowBubbles and BubbleLocation, DayOpen, "Open: " + (if ShowPricesInBubbles then AsText(DayOpen) else ""), GlobalColor("Open"));

DefineGlobalColor("High_of_Day", CreateColor(102, 178, 255));
AddChartBubble(ShowBubbles and BubbleLocation, High_of_Day, "HOD: " + (if ShowPricesInBubbles then AsText(High_of_Day) else ""), GlobalColor("High_of_Day"));

DefineGlobalColor("Low_of_Day", CreateColor(102, 178, 255));
AddChartBubble(ShowBubbles and BubbleLocation, Low_of_Day, "LOD: " + (if ShowPricesInBubbles then AsText(Low_of_Day) else ""), GlobalColor("Low_of_Day"), no);

#----- ATR Lines -----# Thaanks to TraderKevin
input showAtrLines = Yes;
input atrLinesFrom = {default pdc, dayOpen};
input ATRlength = 14;
input averageType = AverageType.WILDERS;

def ATR = MovingAverage(averageType, TrueRange(high(period = ”DAY”)[1], close(period = ”DAY”)[1], low(period = ”DAY”)[1]), ATRlength);

plot hatr = if atrLinesFrom == atrLinesFrom .dayOpen then DayOpen + ATR else PD_Close + ATR;
plot latr = if atrLinesFrom == atrLinesFrom .dayOpen then DayOpen - ATR else PD_Close - ATR;

hatr.SetLineWeight(5);
hatr.SetDefaultColor(Color.RED);
hatr.SetStyle(Curve.LONG_DASH);
hatr.HideBubble();
hatr.HideTitle();
hatr.SetHiding(showAtrLines == no);

latr.SetLineWeight(5);
latr.SetStyle(Curve.LONG_DASH);
latr.SetDefaultColor(Color.GREEN);
latr.HideBubble();
latr.HideTitle();
latr.SetHiding(showAtrLines == no);

DefineGlobalColor("hatr", Color.PINK);
AddChartBubble(ShowBubbles and showAtrLines and BubbleLocation, hatr, "ATRH: " + (if ShowPricesInBubbles then AsText(hatr) else ""), GlobalColor("hatr"));

DefineGlobalColor("latr", Color.LIGHT_GREEN);
AddChartBubble(ShowBubbles and showAtrLines and BubbleLocation, latr, "ATRL: " + (if ShowPricesInBubbles then AsText(latr) else ""), GlobalColor("latr"), no);
 
Hi,

Can anyone help in adding Fib levels to following indicator below. Thank you!
@samer800 @chewie76
@SleepyZ

I would like fib levels with fib extension to be plotted.

1) Fib levels with fib extension from Pre Market Low to Pre Market High

2) Fib levels with fib extension from Pre Market high to Pre Market Low.

3) fib numbers plot as well as price on the line

# Previous Day High/Low/Close + Premarket High/Low + High/Low/Open of Day + ATR Lines
# Created by Wiinii
# V1.6
# Some code based on code by Mobius (premarket) and TraderKevin (ATR lines
# https://usethinkscript.com/threads/...w-high-low-open-of-day-for-thinkorswim.13139/

declare hide_on_daily;

input length = 1;
input showOnlyLastPeriod = yes;
input ShowBubbles = yes;
input locate_bubbles_at = {default Expansion, Time};
input locate_bubbles_at_time = 800;
input BarsFromExpansion = 1;
input ShowPricesInBubbles = yes;

def bn = BarNumber();
def na = Double.NaN;
def h = high;
def l = low;
def o = open;
def c = close;
def v = volume;
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];
}

PD_High.SetDefaultColor(Color.DARK_ORANGE);
PD_High.SetStyle(Curve.LONG_DASH);
PD_High.SetLineWeight(2);
PD_High.HideTitle();

PD_Low.SetDefaultColor(Color.DARK_ORANGE);
PD_Low.SetStyle(Curve.LONG_DASH);
PD_Low.SetLineWeight(2);
PD_Low.HideTitle();

PD_Close.SetDefaultColor(Color.WHITE);
PD_Close.SetStyle(Curve.LONG_DASH);
PD_Close.SetLineWeight(2);
PD_Close.HideTitle();

DefineGlobalColor("PD_High", CreateColor(255, 204, 153));
AddChartBubble(ShowBubbles and BubbleLocation, PD_High, "PDH: " + (if ShowPricesInBubbles then AsText(PD_High) else ""), GlobalColor("PD_High"));

DefineGlobalColor("PD_Low", CreateColor(255, 204, 153));
AddChartBubble(ShowBubbles and BubbleLocation, PD_Low, "PDL: " + (if ShowPricesInBubbles then AsText(PD_Low) else ""), GlobalColor("PD_Low"), no);

DefineGlobalColor("PD_Close", Color.WHITE);
AddChartBubble(ShowBubbles and BubbleLocation, PD_Close, "PDC: " + (if ShowPricesInBubbles then AsText(PD_Close) else ""), GlobalColor("PD_Close"));

PD_High.HideBubble();
PD_Low.HideBubble();
PD_Close.HideBubble();


#----- Premarket High/Low -----# Thanks to Mobius

def GlobeX = GetTime() < RegularTradingStart(GetYYYYMMDD());

def vol = if GlobeX and !GlobeX[1]
then v
else if GlobeX
then vol[1] + v
else na;

def GlobeX_Volume = vol;

def ONhigh = if GlobeX and !GlobeX[1]
then h
else if GlobeX and
h > ONhigh[1]
then h
else ONhigh[1];

def ONhighBar = if GlobeX and h == ONhigh
then bn
else na;

def ONlow = if GlobeX and !GlobeX[1]
then l
else if GlobeX and
l < ONlow[1]
then l
else ONlow[1];

def ONlowBar = if GlobeX and l == ONlow
then bn
else na;

def OverNightHigh = if BarNumber() == HighestAll(ONhighBar)
then ONhigh
else OverNightHigh[1];

def OverNightLow = if BarNumber() == HighestAll(ONlowBar)
then ONlow
else OverNightLow[1];

plot PM_High;
plot PM_Low;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
PM_High = na;
PM_Low = na;
} else {
PM_High = if OverNightHigh > 0 then OverNightHigh else na;
PM_Low = if OverNightLow > 0 then OverNightLow else na;
}

#PM_High.SetHiding(!PlotOverNightExtremes);
PM_High.SetLineWeight(2);
PM_High.SetDefaultColor(Color.CYAN);
PM_High.SetStyle(Curve.LONG_DASH);
PM_High.HideBubble();
PM_High.HideTitle();

#PM_Low.SetHiding(!PlotOverNightExtremes);
PM_Low.SetStyle(Curve.LONG_DASH);
PM_Low.SetDefaultColor(Color.CYAN);
PM_Low.HideBubble();
PM_Low.HideTitle();

DefineGlobalColor("PM_High", CreateColor(102, 255, 255));
AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONhighBar else isExpansion and firstExpansionBar == BarsFromExpansion, PM_High, "PMH: " + (if ShowPricesInBubbles then AsText(PM_High) else ""), GlobalColor("PM_High"));

DefineGlobalColor("PM_Low", CreateColor(102, 255, 255));
AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONlowBar else isExpansion and firstExpansionBar == BarsFromExpansion, PM_Low, "PML: " + (if ShowPricesInBubbles then AsText(PM_Low) else ""), GlobalColor("PM_Low"), no);


#----- Today Open/High/Low -----#


plot High_of_Day;
plot Low_of_Day;
plot DayOpen;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
DayOpen = na;
High_of_Day = na;
Low_of_Day = na;
} else {
DayOpen = open(period = aggregationPeriod)[0];
High_of_Day = Highest(high(period = aggregationPeriod), length);
Low_of_Day = Lowest(low(period = aggregationPeriod), length);
}

DayOpen.SetDefaultColor (Color.GRAY);
DayOpen.SetPaintingStrategy(PaintingStrategy.DASHES);
DayOpen.SetLineWeight(2);
DayOpen.HideTitle();

High_of_Day.SetDefaultColor(CreateColor(0, 128, 255));
High_of_Day.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
High_of_Day.SetLineWeight(2);
High_of_Day.HideTitle();

Low_of_Day.SetDefaultColor(CreateColor(0, 128, 255));
Low_of_Day.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Low_of_Day.SetLineWeight(2);
Low_of_Day.HideTitle();

DefineGlobalColor("Open", Color.LIGHT_GRAY);
AddChartBubble(ShowBubbles and BubbleLocation, DayOpen, "Open: " + (if ShowPricesInBubbles then AsText(DayOpen) else ""), GlobalColor("Open"));

DefineGlobalColor("High_of_Day", CreateColor(102, 178, 255));
AddChartBubble(ShowBubbles and BubbleLocation, High_of_Day, "HOD: " + (if ShowPricesInBubbles then AsText(High_of_Day) else ""), GlobalColor("High_of_Day"));

DefineGlobalColor("Low_of_Day", CreateColor(102, 178, 255));
AddChartBubble(ShowBubbles and BubbleLocation, Low_of_Day, "LOD: " + (if ShowPricesInBubbles then AsText(Low_of_Day) else ""), GlobalColor("Low_of_Day"), no);

#----- ATR Lines -----# Thaanks to TraderKevin
input showAtrLines = Yes;
input atrLinesFrom = {default pdc, dayOpen};
input ATRlength = 14;
input averageType = AverageType.WILDERS;

def ATR = MovingAverage(averageType, TrueRange(high(period = ”DAY”)[1], close(period = ”DAY”)[1], low(period = ”DAY”)[1]), ATRlength);

plot hatr = if atrLinesFrom == atrLinesFrom .dayOpen then DayOpen + ATR else PD_Close + ATR;
plot latr = if atrLinesFrom == atrLinesFrom .dayOpen then DayOpen - ATR else PD_Close - ATR;

hatr.SetLineWeight(5);
hatr.SetDefaultColor(Color.RED);
hatr.SetStyle(Curve.LONG_DASH);
hatr.HideBubble();
hatr.HideTitle();
hatr.SetHiding(showAtrLines == no);

latr.SetLineWeight(5);
latr.SetStyle(Curve.LONG_DASH);
latr.SetDefaultColor(Color.GREEN);
latr.HideBubble();
latr.HideTitle();
latr.SetHiding(showAtrLines == no);

DefineGlobalColor("hatr", Color.PINK);
AddChartBubble(ShowBubbles and showAtrLines and BubbleLocation, hatr, "ATRH: " + (if ShowPricesInBubbles then AsText(hatr) else ""), GlobalColor("hatr"));

DefineGlobalColor("latr", Color.LIGHT_GREEN);
AddChartBubble(ShowBubbles and showAtrLines and BubbleLocation, latr, "ATRL: " + (if ShowPricesInBubbles then AsText(latr) else ""), GlobalColor("latr"), no);
Try this.
Code:
# Previous Day High/Low/Close + Premarket High/Low + High/Low/Open of Day + ATR Lines
# Created by Wiinii
# V1.6
# Some code based on code by Mobius (premarket) and TraderKevin (ATR lines
# https://usethinkscript.com/threads/previous-day-high-low-close-premarket-high-low-high-low-open-of-day-for-thinkorswim.13139/

declare hide_on_daily;

input length = 1;
input showOnlyLastPeriod = no;
input ShowBubbles = yes;
input locate_bubbles_at = {default Expansion, Time};
input locate_bubbles_at_time = 800;
input BarsFromExpansion = 15;
input ShowPricesInBubbles = yes;

def bn = BarNumber();
def na = Double.NaN;
def h  = high;
def l  = low;
def o = open;
def c = close;
def v = volume;
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];
}

PD_High.SetDefaultColor(Color.red);
PD_High.SetStyle(Curve.medium_DASH);
PD_High.SetLineWeight(2);
PD_High.HideTitle();

PD_Low.SetDefaultColor(Color.red);
PD_Low.SetStyle(Curve.medium_DASH);
PD_Low.SetLineWeight(2);
PD_Low.HideTitle();

PD_Close.SetDefaultColor(Color.YELLOW);
PD_Close.SetPaintingStrategy(PaintingStrategy.line);
PD_Close.SetLineWeight(2);
PD_Close.HideTitle();

DefineGlobalColor("PD_High", CreateColor(255, 204, 153));
AddChartBubble(ShowBubbles and BubbleLocation, PD_High, "PDH: " + (if ShowPricesInBubbles then AsText(PD_High) else ""), GlobalColor("PD_High"));

DefineGlobalColor("PD_Low", CreateColor(255, 204, 153));
AddChartBubble(ShowBubbles and BubbleLocation, PD_Low, "PDL: " + (if ShowPricesInBubbles then AsText(PD_Low) else ""), GlobalColor("PD_Low"), no);

DefineGlobalColor("PD_Close", Color.WHITE);
AddChartBubble(ShowBubbles and BubbleLocation, PD_Close, "PDC: " + (if ShowPricesInBubbles then AsText(PD_Close) else ""), GlobalColor("PD_Close"));

PD_High.HideBubble();
PD_Low.HideBubble();
PD_Close.HideBubble();


#----- Premarket High/Low -----# Thanks to Mobius

def GlobeX = GetTime() < RegularTradingStart(GetYYYYMMDD());

def vol = if GlobeX and !GlobeX[1]
then v
else if GlobeX
then vol[1] + v
else na;

def GlobeX_Volume = vol;

def ONhigh = if GlobeX and !GlobeX[1]
then h
else if GlobeX and
h > ONhigh[1]
then h
else ONhigh[1];

def ONhighBar = if GlobeX and h == ONhigh
then bn
else na;

def ONlow = if GlobeX and !GlobeX[1]
then l
else if GlobeX and
l < ONlow[1]
then l
else ONlow[1];

def ONlowBar = if GlobeX and l == ONlow
then bn
else na;

def OverNightHigh = if BarNumber() == HighestAll(ONhighBar)
then ONhigh
else OverNightHigh[1];

def OverNightLow = if BarNumber() == HighestAll(ONlowBar)
then ONlow
else OverNightLow[1];

plot PM_High;
plot PM_Low;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
    PM_High = na;
    PM_Low = na;
} else {
    PM_High = if OverNightHigh > 0 then OverNightHigh else na;
    PM_Low = if OverNightLow > 0 then OverNightLow else na;
}

#PM_High.SetHiding(!PlotOverNightExtremes);
PM_High.SetLineWeight(5);
PM_High.SetDefaultColor(Color.red);
#PM_High.SetStyle(Curve.LONG_DASH);
PM_High.HideBubble();
PM_High.HideTitle();

#PM_Low.SetHiding(!PlotOverNightExtremes);
PM_Low.SetLineWeight(5);
#PM_Low.SetStyle(Curve.LONG_DASH);
PM_Low.SetDefaultColor(Color.red);
PM_Low.HideBubble();
PM_Low.HideTitle();

DefineGlobalColor("PM_High", CreateColor(102, 255, 255));
AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONhighBar else isExpansion and firstExpansionBar == BarsFromExpansion, PM_High, "PMH: " + (if ShowPricesInBubbles then AsText(PM_High) else ""), GlobalColor("PM_High"));

DefineGlobalColor("PM_Low", CreateColor(102, 255, 255));
AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONlowBar else isExpansion and firstExpansionBar == BarsFromExpansion, PM_Low, "PML: " + (if ShowPricesInBubbles then AsText(PM_Low) else ""), GlobalColor("PM_Low"), no);

#PM FIBS
def fib1Level = 11.4;
def fib2Level = 21.4;
def fib3Level = 38.2;
def fib4Level = 50;
def fib5Level = 61.8;
def fib6Level = 76.4;
def fib7Level = 85.4;
def fib8Level = 123.6;
def fib9Level = -23.6;
def fib10Level = 150;
def fib11Level = -50;
def fib12Level = 162;
def fib13Level = -62;
def fib14Level = 179;
def fib15Level = -79;
def fib16Level = 200;
def fib17Level = -100;

def f1 = pm_low + (pm_high - pm_low) * fib1Level / 100;
def f2 = pm_low + (pm_high - pm_low) * fib2Level / 100;
def f3 = pm_low + (pm_high - pm_low) * fib3Level / 100;
def f4 = pm_low + (pm_high - pm_low) * fib4Level / 100;
def f5 = pm_low + (pm_high - pm_low) * fib5Level / 100;
def f6 = pm_low + (pm_high - pm_low) * fib6Level / 100;
def f7 = pm_low + (pm_high - pm_low) * fib7Level / 100;
def f8 = pm_low + (pm_high - pm_low) * fib8Level / 100;
def f9 = pm_low + (pm_high - pm_low) * fib9Level / 100;
def f10 = pm_low + (pm_high - pm_low) * fib10Level / 100;
def f11 = pm_low + (pm_high - pm_low) * fib11Level / 100;
def f12 = pm_low + (pm_high - pm_low) * fib12Level / 100;
def f13 = pm_low + (pm_high - pm_low) * fib13Level / 100;
def f14 = pm_low + (pm_high - pm_low) * fib14Level / 100;
def f15 = pm_low + (pm_high - pm_low) * fib15Level / 100;
def f16 = pm_low + (pm_high - pm_low) * fib16Level / 100;
def f17 = pm_low + (pm_high - pm_low) * fib17Level / 100;

plot Fib1 = f1;
#plot Fib1 = if close > f4 then f1 else double.nan;
plot Fib2 = f2;
plot Fib3 = f3;
plot Fib4 = f4;
plot Fib5 = f5;
plot Fib6 = f6;
plot Fib7 = f7;
plot Fib8 = f8;
plot Fib9 = f9;
plot Fib10 = f10;
plot Fib11 = f11;
plot Fib12 = f12;
plot Fib13 = f13;
plot Fib14 = f14;
plot Fib15 = f15;
plot Fib16 = f16;
plot Fib17 = f17;

Fib1.SetPaintingStrategy(PaintingStrategy.dashes);
Fib1.SetDefaultColor(Color.blue);
Fib1.HideBubble();
Fib2.SetPaintingStrategy(PaintingStrategy.dashes);
Fib2.SetDefaultColor(Color.cyan);
Fib2.HideBubble();

Fib3.SetPaintingStrategy(PaintingStrategy.dashes);
Fib3.SetDefaultColor(Color.orange);
Fib3.HideBubble();

Fib4.SetPaintingStrategy(PaintingStrategy.dashes);
Fib4.SetDefaultColor(Color.green);
Fib4.HideBubble();

Fib5.SetPaintingStrategy(PaintingStrategy.dashes);
Fib5.SetDefaultColor(Color.orange);
Fib5.HideBubble();

Fib6.SetPaintingStrategy(PaintingStrategy.dashes);
Fib6.SetDefaultColor(Color.cyan);
Fib6.HideBubble();

Fib7.SetPaintingStrategy(PaintingStrategy.dashes);
Fib7.SetDefaultColor(Color.blue);
Fib7.HideBubble();

Fib8.SetPaintingStrategy(PaintingStrategy.dashes);
Fib8.SetDefaultColor(Color.cyan);
Fib8.setlineWeight(1);
Fib8.HideBubble();

Fib9.SetPaintingStrategy(PaintingStrategy.dashes);
Fib9.SetDefaultColor(Color.cyan);
Fib9.setlineWeight(1);
Fib9.HideBubble();

Fib10.SetPaintingStrategy(PaintingStrategy.dashes);
Fib10.SetDefaultColor(Color.green);
Fib10.setlineWeight(1);
Fib10.HideBubble();

Fib11.SetPaintingStrategy(PaintingStrategy.dashes);
Fib11.SetDefaultColor(Color.green);
Fib11.setlineWeight(1);
Fib11.HideBubble();

Fib12.SetPaintingStrategy(PaintingStrategy.dashes);
Fib12.SetDefaultColor(Color.orange);
Fib12.setlineWeight(2);
Fib12.HideBubble();

Fib13.SetPaintingStrategy(PaintingStrategy.dashes);
Fib13.SetDefaultColor(Color.orange);
Fib13.setlineWeight(2);
Fib13.HideBubble();

Fib14.SetPaintingStrategy(PaintingStrategy.dashes);
Fib14.SetDefaultColor(Color.dark_red);
Fib14.setlineWeight(2);
Fib14.HideBubble();

Fib15.SetPaintingStrategy(PaintingStrategy.dashes);
Fib15.SetDefaultColor(Color.dark_red);
Fib15.setlineWeight(2);
Fib15.HideBubble();

Fib16.SetPaintingStrategy(PaintingStrategy.dashes);
Fib16.SetDefaultColor(Color.white);
Fib16.setlineWeight(2);
Fib16.HideBubble();

Fib17.SetPaintingStrategy(PaintingStrategy.dashes);
Fib17.SetDefaultColor(Color.white);
Fib17.setlineWeight(2);
Fib17.HideBubble();

AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONlowBar else isExpansion and firstExpansionBar == BarsFromExpansion, Fib8, "50%: " + (if ShowPricesInBubbles then AsText(Fib8) else ""), color.white);

AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONlowBar else isExpansion and firstExpansionBar == BarsFromExpansion, Fib9, "-50%: " + (if ShowPricesInBubbles then AsText(Fib9) else ""), color.white, no);

AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONlowBar else isExpansion and firstExpansionBar == BarsFromExpansion, Fib10, "100%: " + (if ShowPricesInBubbles then AsText(Fib10) else ""), color.green);

AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONlowBar else isExpansion and firstExpansionBar == BarsFromExpansion, Fib11, "-100%: " + (if ShowPricesInBubbles then AsText(Fib11) else ""), color.green, no);

AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONlowBar else isExpansion and firstExpansionBar == BarsFromExpansion, Fib12, "150%: " + (if ShowPricesInBubbles then AsText(Fib12) else ""), color.white);

AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONlowBar else isExpansion and firstExpansionBar == BarsFromExpansion, Fib13, "-150%: " + (if ShowPricesInBubbles then AsText(Fib13) else ""), color.white, no);

AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONlowBar else isExpansion and firstExpansionBar == BarsFromExpansion, Fib14, "200%: " + (if ShowPricesInBubbles then AsText(Fib14) else ""), color.white);

AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONlowBar else isExpansion and firstExpansionBar == BarsFromExpansion, Fib15, "-200%: " + (if ShowPricesInBubbles then AsText(Fib15) else ""), color.white, no);

#----- Today Open/High/Low -----#


plot High_of_Day;
plot Low_of_Day;
#plot DayOpen;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
    #DayOpen = na;
    High_of_Day = na;
    Low_of_Day = na;
} else {
   # DayOpen = open(period = aggregationPeriod)[0];
    High_of_Day = Highest(high(period = aggregationPeriod), length);
    Low_of_Day = Lowest(low(period = aggregationPeriod), length);
}

#DayOpen.SetDefaultColor (Color.yellow);
#DayOpen.SetPaintingStrategy(PaintingStrategy.DASHES);
#DayOpen.SetLineWeight(2);
#DayOpen.HideTitle();

High_of_Day.SetDefaultColor(CreateColor(0, 128, 255));
High_of_Day.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
High_of_Day.SetLineWeight(2);
High_of_Day.HideTitle();

Low_of_Day.SetDefaultColor(CreateColor(0, 128, 255));
Low_of_Day.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Low_of_Day.SetLineWeight(2);
Low_of_Day.HideTitle();


def Dfib1Level = 123.6;
def Dfib2Level = -23.6;
def Dfib3Level = 150;
def Dfib4Level = -50;
def Dfib5Level = 162;
def Dfib6Level = -62;
def Dfib7Level = 179;
def Dfib8Level = -79;
def Dfib9Level = 200;
def Dfib10Level = -100;

def Df1 = Low_of_Day + (High_of_Day - Low_of_Day) * Dfib1Level / 100;
def Df2 = Low_of_Day + (High_of_Day - Low_of_Day) * Dfib2Level / 100;
def Df3 = Low_of_Day + (High_of_Day - Low_of_Day) * Dfib3Level / 100;
def Df4 = Low_of_Day + (High_of_Day - Low_of_Day) * Dfib4Level / 100;
def Df5 = Low_of_Day + (High_of_Day - Low_of_Day) * Dfib5Level / 100;
def Df6 = Low_of_Day + (High_of_Day - Low_of_Day) * Dfib6Level / 100;
def Df7 = Low_of_Day + (High_of_Day - Low_of_Day) * Dfib7Level / 100;
def Df8 = Low_of_Day + (High_of_Day - Low_of_Day) * Dfib8Level / 100;
def Df9 = Low_of_Day + (High_of_Day - Low_of_Day) * Dfib9Level / 100;
def Df10 = Low_of_Day + (High_of_Day - Low_of_Day) * Dfib10Level / 100;

plot DFib1 = Df1;
plot DFib2 = Df2;
plot DFib3 = Df3;
plot DFib4 = Df4;
plot DFib5 = Df5;
plot DFib6 = Df6;
plot DFib7 = Df7;
plot DFib8 = Df8;
plot DFib9 = Df9;
plot DFib10 = Df10;

DFib1.SetPaintingStrategy(PaintingStrategy.dashes);
DFib1.SetDefaultColor(Color.cyan);
DFib1.setlineWeight(1);
DFib1.HideBubble();

DFib2.SetPaintingStrategy(PaintingStrategy.dashes);
DFib2.SetDefaultColor(Color.cyan);
DFib2.setlineWeight(1);
DFib2.HideBubble();

DFib3.SetPaintingStrategy(PaintingStrategy.dashes);
DFib3.SetDefaultColor(Color.green);
DFib3.setlineWeight(1);
DFib3.HideBubble();

DFib4.SetPaintingStrategy(PaintingStrategy.dashes);
DFib4.SetDefaultColor(Color.green);
DFib4.setlineWeight(1);
DFib4.HideBubble();

DFib5.SetPaintingStrategy(PaintingStrategy.dashes);
DFib5.SetDefaultColor(Color.orange);
DFib5.setlineWeight(2);
DFib5.HideBubble();

DFib6.SetPaintingStrategy(PaintingStrategy.dashes);
DFib6.SetDefaultColor(Color.orange);
DFib6.setlineWeight(2);
DFib6.HideBubble();

DFib7.SetPaintingStrategy(PaintingStrategy.dashes);
DFib7.SetDefaultColor(Color.dark_red);
DFib7.setlineWeight(2);
DFib7.HideBubble();

DFib8.SetPaintingStrategy(PaintingStrategy.dashes);
DFib8.SetDefaultColor(Color.dark_red);
DFib8.setlineWeight(2);
DFib8.HideBubble();

DFib9.SetPaintingStrategy(PaintingStrategy.dashes);
DFib9.SetDefaultColor(Color.white);
DFib9.setlineWeight(2);
DFib9.HideBubble();

DFib10.SetPaintingStrategy(PaintingStrategy.dashes);
DFib10.SetDefaultColor(Color.white);
DFib10.setlineWeight(2);
DFib10.HideBubble();

DefineGlobalColor("Open", Color.yellow);
#AddChartBubble(ShowBubbles and BubbleLocation, DayOpen, "Open: " + (if ShowPricesInBubbles then AsText(DayOpen) else ""), GlobalColor("Open"));

DefineGlobalColor("High_of_Day", CreateColor(102, 178, 255));
AddChartBubble(ShowBubbles and BubbleLocation, High_of_Day, "HOD: " + (if ShowPricesInBubbles then AsText(High_of_Day) else ""), GlobalColor("High_of_Day"));

DefineGlobalColor("Low_of_Day", CreateColor(102, 178, 255));
AddChartBubble(ShowBubbles and BubbleLocation, Low_of_Day, "LOD: " + (if ShowPricesInBubbles then AsText(Low_of_Day) else ""), GlobalColor("Low_of_Day"), no);

#----- ATR Lines -----# Thaanks to TraderKevin
#input showAtrLines = Yes;
#input atrLinesFrom = {default pdc, dayOpen};
#input ATRlength = 14;
#input averageType = AverageType.WILDERS;

#def ATR = MovingAverage(averageType, TrueRange(high(period = ”DAY”)[1], close(period = ”DAY”)[1], low(period = ”DAY”)[1]), ATRlength);

#plot hatr = if atrLinesFrom  == atrLinesFrom .dayOpen then DayOpen + ATR else PD_Close + ATR;
#plot latr = if atrLinesFrom  == atrLinesFrom .dayOpen then DayOpen - ATR else PD_Close - ATR;

#hatr.SetLineWeight(5);
#hatr.SetDefaultColor(Color.RED);
#hatr.SetStyle(Curve.LONG_DASH);
#hatr.HideBubble();
#hatr.HideTitle();
#hatr.SetHiding(showAtrLines == no);

#latr.SetLineWeight(5);
#latr.SetStyle(Curve.LONG_DASH);
#latr.SetDefaultColor(Color.GREEN);
#latr.HideBubble();
#latr.HideTitle();
#latr.SetHiding(showAtrLines == no);

#DefineGlobalColor("hatr", Color.PINK);
#AddChartBubble(ShowBubbles and showAtrLines and BubbleLocation, hatr, "ATRH: " + (if ShowPricesInBubbles then AsText(hatr) else ""), GlobalColor("hatr"));

#DefineGlobalColor("latr", Color.LIGHT_GREEN);
#AddChartBubble(ShowBubbles and showAtrLines and BubbleLocation, latr, "ATRL: " + (if ShowPricesInBubbles then AsText(latr) else ""), GlobalColor("latr"), no);
 
Try this.
Code:
# Previous Day High/Low/Close + Premarket High/Low + High/Low/Open of Day + ATR Lines
# Created by Wiinii
# V1.6
# Some code based on code by Mobius (premarket) and TraderKevin (ATR lines
# https://usethinkscript.com/threads/previous-day-high-low-close-premarket-high-low-high-low-open-of-day-for-thinkorswim.13139/

declare hide_on_daily;

input length = 1;
input showOnlyLastPeriod = no;
input ShowBubbles = yes;
input locate_bubbles_at = {default Expansion, Time};
input locate_bubbles_at_time = 800;
input BarsFromExpansion = 15;
input ShowPricesInBubbles = yes;

def bn = BarNumber();
def na = Double.NaN;
def h  = high;
def l  = low;
def o = open;
def c = close;
def v = volume;
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];
}

PD_High.SetDefaultColor(Color.red);
PD_High.SetStyle(Curve.medium_DASH);
PD_High.SetLineWeight(2);
PD_High.HideTitle();

PD_Low.SetDefaultColor(Color.red);
PD_Low.SetStyle(Curve.medium_DASH);
PD_Low.SetLineWeight(2);
PD_Low.HideTitle();

PD_Close.SetDefaultColor(Color.YELLOW);
PD_Close.SetPaintingStrategy(PaintingStrategy.line);
PD_Close.SetLineWeight(2);
PD_Close.HideTitle();

DefineGlobalColor("PD_High", CreateColor(255, 204, 153));
AddChartBubble(ShowBubbles and BubbleLocation, PD_High, "PDH: " + (if ShowPricesInBubbles then AsText(PD_High) else ""), GlobalColor("PD_High"));

DefineGlobalColor("PD_Low", CreateColor(255, 204, 153));
AddChartBubble(ShowBubbles and BubbleLocation, PD_Low, "PDL: " + (if ShowPricesInBubbles then AsText(PD_Low) else ""), GlobalColor("PD_Low"), no);

DefineGlobalColor("PD_Close", Color.WHITE);
AddChartBubble(ShowBubbles and BubbleLocation, PD_Close, "PDC: " + (if ShowPricesInBubbles then AsText(PD_Close) else ""), GlobalColor("PD_Close"));

PD_High.HideBubble();
PD_Low.HideBubble();
PD_Close.HideBubble();


#----- Premarket High/Low -----# Thanks to Mobius

def GlobeX = GetTime() < RegularTradingStart(GetYYYYMMDD());

def vol = if GlobeX and !GlobeX[1]
then v
else if GlobeX
then vol[1] + v
else na;

def GlobeX_Volume = vol;

def ONhigh = if GlobeX and !GlobeX[1]
then h
else if GlobeX and
h > ONhigh[1]
then h
else ONhigh[1];

def ONhighBar = if GlobeX and h == ONhigh
then bn
else na;

def ONlow = if GlobeX and !GlobeX[1]
then l
else if GlobeX and
l < ONlow[1]
then l
else ONlow[1];

def ONlowBar = if GlobeX and l == ONlow
then bn
else na;

def OverNightHigh = if BarNumber() == HighestAll(ONhighBar)
then ONhigh
else OverNightHigh[1];

def OverNightLow = if BarNumber() == HighestAll(ONlowBar)
then ONlow
else OverNightLow[1];

plot PM_High;
plot PM_Low;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
    PM_High = na;
    PM_Low = na;
} else {
    PM_High = if OverNightHigh > 0 then OverNightHigh else na;
    PM_Low = if OverNightLow > 0 then OverNightLow else na;
}

#PM_High.SetHiding(!PlotOverNightExtremes);
PM_High.SetLineWeight(5);
PM_High.SetDefaultColor(Color.red);
#PM_High.SetStyle(Curve.LONG_DASH);
PM_High.HideBubble();
PM_High.HideTitle();

#PM_Low.SetHiding(!PlotOverNightExtremes);
PM_Low.SetLineWeight(5);
#PM_Low.SetStyle(Curve.LONG_DASH);
PM_Low.SetDefaultColor(Color.red);
PM_Low.HideBubble();
PM_Low.HideTitle();

DefineGlobalColor("PM_High", CreateColor(102, 255, 255));
AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONhighBar else isExpansion and firstExpansionBar == BarsFromExpansion, PM_High, "PMH: " + (if ShowPricesInBubbles then AsText(PM_High) else ""), GlobalColor("PM_High"));

DefineGlobalColor("PM_Low", CreateColor(102, 255, 255));
AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONlowBar else isExpansion and firstExpansionBar == BarsFromExpansion, PM_Low, "PML: " + (if ShowPricesInBubbles then AsText(PM_Low) else ""), GlobalColor("PM_Low"), no);

#PM FIBS
def fib1Level = 11.4;
def fib2Level = 21.4;
def fib3Level = 38.2;
def fib4Level = 50;
def fib5Level = 61.8;
def fib6Level = 76.4;
def fib7Level = 85.4;
def fib8Level = 123.6;
def fib9Level = -23.6;
def fib10Level = 150;
def fib11Level = -50;
def fib12Level = 162;
def fib13Level = -62;
def fib14Level = 179;
def fib15Level = -79;
def fib16Level = 200;
def fib17Level = -100;

def f1 = pm_low + (pm_high - pm_low) * fib1Level / 100;
def f2 = pm_low + (pm_high - pm_low) * fib2Level / 100;
def f3 = pm_low + (pm_high - pm_low) * fib3Level / 100;
def f4 = pm_low + (pm_high - pm_low) * fib4Level / 100;
def f5 = pm_low + (pm_high - pm_low) * fib5Level / 100;
def f6 = pm_low + (pm_high - pm_low) * fib6Level / 100;
def f7 = pm_low + (pm_high - pm_low) * fib7Level / 100;
def f8 = pm_low + (pm_high - pm_low) * fib8Level / 100;
def f9 = pm_low + (pm_high - pm_low) * fib9Level / 100;
def f10 = pm_low + (pm_high - pm_low) * fib10Level / 100;
def f11 = pm_low + (pm_high - pm_low) * fib11Level / 100;
def f12 = pm_low + (pm_high - pm_low) * fib12Level / 100;
def f13 = pm_low + (pm_high - pm_low) * fib13Level / 100;
def f14 = pm_low + (pm_high - pm_low) * fib14Level / 100;
def f15 = pm_low + (pm_high - pm_low) * fib15Level / 100;
def f16 = pm_low + (pm_high - pm_low) * fib16Level / 100;
def f17 = pm_low + (pm_high - pm_low) * fib17Level / 100;

plot Fib1 = f1;
#plot Fib1 = if close > f4 then f1 else double.nan;
plot Fib2 = f2;
plot Fib3 = f3;
plot Fib4 = f4;
plot Fib5 = f5;
plot Fib6 = f6;
plot Fib7 = f7;
plot Fib8 = f8;
plot Fib9 = f9;
plot Fib10 = f10;
plot Fib11 = f11;
plot Fib12 = f12;
plot Fib13 = f13;
plot Fib14 = f14;
plot Fib15 = f15;
plot Fib16 = f16;
plot Fib17 = f17;

Fib1.SetPaintingStrategy(PaintingStrategy.dashes);
Fib1.SetDefaultColor(Color.blue);
Fib1.HideBubble();
Fib2.SetPaintingStrategy(PaintingStrategy.dashes);
Fib2.SetDefaultColor(Color.cyan);
Fib2.HideBubble();

Fib3.SetPaintingStrategy(PaintingStrategy.dashes);
Fib3.SetDefaultColor(Color.orange);
Fib3.HideBubble();

Fib4.SetPaintingStrategy(PaintingStrategy.dashes);
Fib4.SetDefaultColor(Color.green);
Fib4.HideBubble();

Fib5.SetPaintingStrategy(PaintingStrategy.dashes);
Fib5.SetDefaultColor(Color.orange);
Fib5.HideBubble();

Fib6.SetPaintingStrategy(PaintingStrategy.dashes);
Fib6.SetDefaultColor(Color.cyan);
Fib6.HideBubble();

Fib7.SetPaintingStrategy(PaintingStrategy.dashes);
Fib7.SetDefaultColor(Color.blue);
Fib7.HideBubble();

Fib8.SetPaintingStrategy(PaintingStrategy.dashes);
Fib8.SetDefaultColor(Color.cyan);
Fib8.setlineWeight(1);
Fib8.HideBubble();

Fib9.SetPaintingStrategy(PaintingStrategy.dashes);
Fib9.SetDefaultColor(Color.cyan);
Fib9.setlineWeight(1);
Fib9.HideBubble();

Fib10.SetPaintingStrategy(PaintingStrategy.dashes);
Fib10.SetDefaultColor(Color.green);
Fib10.setlineWeight(1);
Fib10.HideBubble();

Fib11.SetPaintingStrategy(PaintingStrategy.dashes);
Fib11.SetDefaultColor(Color.green);
Fib11.setlineWeight(1);
Fib11.HideBubble();

Fib12.SetPaintingStrategy(PaintingStrategy.dashes);
Fib12.SetDefaultColor(Color.orange);
Fib12.setlineWeight(2);
Fib12.HideBubble();

Fib13.SetPaintingStrategy(PaintingStrategy.dashes);
Fib13.SetDefaultColor(Color.orange);
Fib13.setlineWeight(2);
Fib13.HideBubble();

Fib14.SetPaintingStrategy(PaintingStrategy.dashes);
Fib14.SetDefaultColor(Color.dark_red);
Fib14.setlineWeight(2);
Fib14.HideBubble();

Fib15.SetPaintingStrategy(PaintingStrategy.dashes);
Fib15.SetDefaultColor(Color.dark_red);
Fib15.setlineWeight(2);
Fib15.HideBubble();

Fib16.SetPaintingStrategy(PaintingStrategy.dashes);
Fib16.SetDefaultColor(Color.white);
Fib16.setlineWeight(2);
Fib16.HideBubble();

Fib17.SetPaintingStrategy(PaintingStrategy.dashes);
Fib17.SetDefaultColor(Color.white);
Fib17.setlineWeight(2);
Fib17.HideBubble();

AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONlowBar else isExpansion and firstExpansionBar == BarsFromExpansion, Fib8, "50%: " + (if ShowPricesInBubbles then AsText(Fib8) else ""), color.white);

AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONlowBar else isExpansion and firstExpansionBar == BarsFromExpansion, Fib9, "-50%: " + (if ShowPricesInBubbles then AsText(Fib9) else ""), color.white, no);

AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONlowBar else isExpansion and firstExpansionBar == BarsFromExpansion, Fib10, "100%: " + (if ShowPricesInBubbles then AsText(Fib10) else ""), color.green);

AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONlowBar else isExpansion and firstExpansionBar == BarsFromExpansion, Fib11, "-100%: " + (if ShowPricesInBubbles then AsText(Fib11) else ""), color.green, no);

AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONlowBar else isExpansion and firstExpansionBar == BarsFromExpansion, Fib12, "150%: " + (if ShowPricesInBubbles then AsText(Fib12) else ""), color.white);

AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONlowBar else isExpansion and firstExpansionBar == BarsFromExpansion, Fib13, "-150%: " + (if ShowPricesInBubbles then AsText(Fib13) else ""), color.white, no);

AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONlowBar else isExpansion and firstExpansionBar == BarsFromExpansion, Fib14, "200%: " + (if ShowPricesInBubbles then AsText(Fib14) else ""), color.white);

AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONlowBar else isExpansion and firstExpansionBar == BarsFromExpansion, Fib15, "-200%: " + (if ShowPricesInBubbles then AsText(Fib15) else ""), color.white, no);

#----- Today Open/High/Low -----#


plot High_of_Day;
plot Low_of_Day;
#plot DayOpen;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
    #DayOpen = na;
    High_of_Day = na;
    Low_of_Day = na;
} else {
   # DayOpen = open(period = aggregationPeriod)[0];
    High_of_Day = Highest(high(period = aggregationPeriod), length);
    Low_of_Day = Lowest(low(period = aggregationPeriod), length);
}

#DayOpen.SetDefaultColor (Color.yellow);
#DayOpen.SetPaintingStrategy(PaintingStrategy.DASHES);
#DayOpen.SetLineWeight(2);
#DayOpen.HideTitle();

High_of_Day.SetDefaultColor(CreateColor(0, 128, 255));
High_of_Day.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
High_of_Day.SetLineWeight(2);
High_of_Day.HideTitle();

Low_of_Day.SetDefaultColor(CreateColor(0, 128, 255));
Low_of_Day.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Low_of_Day.SetLineWeight(2);
Low_of_Day.HideTitle();


def Dfib1Level = 123.6;
def Dfib2Level = -23.6;
def Dfib3Level = 150;
def Dfib4Level = -50;
def Dfib5Level = 162;
def Dfib6Level = -62;
def Dfib7Level = 179;
def Dfib8Level = -79;
def Dfib9Level = 200;
def Dfib10Level = -100;

def Df1 = Low_of_Day + (High_of_Day - Low_of_Day) * Dfib1Level / 100;
def Df2 = Low_of_Day + (High_of_Day - Low_of_Day) * Dfib2Level / 100;
def Df3 = Low_of_Day + (High_of_Day - Low_of_Day) * Dfib3Level / 100;
def Df4 = Low_of_Day + (High_of_Day - Low_of_Day) * Dfib4Level / 100;
def Df5 = Low_of_Day + (High_of_Day - Low_of_Day) * Dfib5Level / 100;
def Df6 = Low_of_Day + (High_of_Day - Low_of_Day) * Dfib6Level / 100;
def Df7 = Low_of_Day + (High_of_Day - Low_of_Day) * Dfib7Level / 100;
def Df8 = Low_of_Day + (High_of_Day - Low_of_Day) * Dfib8Level / 100;
def Df9 = Low_of_Day + (High_of_Day - Low_of_Day) * Dfib9Level / 100;
def Df10 = Low_of_Day + (High_of_Day - Low_of_Day) * Dfib10Level / 100;

plot DFib1 = Df1;
plot DFib2 = Df2;
plot DFib3 = Df3;
plot DFib4 = Df4;
plot DFib5 = Df5;
plot DFib6 = Df6;
plot DFib7 = Df7;
plot DFib8 = Df8;
plot DFib9 = Df9;
plot DFib10 = Df10;

DFib1.SetPaintingStrategy(PaintingStrategy.dashes);
DFib1.SetDefaultColor(Color.cyan);
DFib1.setlineWeight(1);
DFib1.HideBubble();

DFib2.SetPaintingStrategy(PaintingStrategy.dashes);
DFib2.SetDefaultColor(Color.cyan);
DFib2.setlineWeight(1);
DFib2.HideBubble();

DFib3.SetPaintingStrategy(PaintingStrategy.dashes);
DFib3.SetDefaultColor(Color.green);
DFib3.setlineWeight(1);
DFib3.HideBubble();

DFib4.SetPaintingStrategy(PaintingStrategy.dashes);
DFib4.SetDefaultColor(Color.green);
DFib4.setlineWeight(1);
DFib4.HideBubble();

DFib5.SetPaintingStrategy(PaintingStrategy.dashes);
DFib5.SetDefaultColor(Color.orange);
DFib5.setlineWeight(2);
DFib5.HideBubble();

DFib6.SetPaintingStrategy(PaintingStrategy.dashes);
DFib6.SetDefaultColor(Color.orange);
DFib6.setlineWeight(2);
DFib6.HideBubble();

DFib7.SetPaintingStrategy(PaintingStrategy.dashes);
DFib7.SetDefaultColor(Color.dark_red);
DFib7.setlineWeight(2);
DFib7.HideBubble();

DFib8.SetPaintingStrategy(PaintingStrategy.dashes);
DFib8.SetDefaultColor(Color.dark_red);
DFib8.setlineWeight(2);
DFib8.HideBubble();

DFib9.SetPaintingStrategy(PaintingStrategy.dashes);
DFib9.SetDefaultColor(Color.white);
DFib9.setlineWeight(2);
DFib9.HideBubble();

DFib10.SetPaintingStrategy(PaintingStrategy.dashes);
DFib10.SetDefaultColor(Color.white);
DFib10.setlineWeight(2);
DFib10.HideBubble();

DefineGlobalColor("Open", Color.yellow);
#AddChartBubble(ShowBubbles and BubbleLocation, DayOpen, "Open: " + (if ShowPricesInBubbles then AsText(DayOpen) else ""), GlobalColor("Open"));

DefineGlobalColor("High_of_Day", CreateColor(102, 178, 255));
AddChartBubble(ShowBubbles and BubbleLocation, High_of_Day, "HOD: " + (if ShowPricesInBubbles then AsText(High_of_Day) else ""), GlobalColor("High_of_Day"));

DefineGlobalColor("Low_of_Day", CreateColor(102, 178, 255));
AddChartBubble(ShowBubbles and BubbleLocation, Low_of_Day, "LOD: " + (if ShowPricesInBubbles then AsText(Low_of_Day) else ""), GlobalColor("Low_of_Day"), no);

#----- ATR Lines -----# Thaanks to TraderKevin
#input showAtrLines = Yes;
#input atrLinesFrom = {default pdc, dayOpen};
#input ATRlength = 14;
#input averageType = AverageType.WILDERS;

#def ATR = MovingAverage(averageType, TrueRange(high(period = ”DAY”)[1], close(period = ”DAY”)[1], low(period = ”DAY”)[1]), ATRlength);

#plot hatr = if atrLinesFrom  == atrLinesFrom .dayOpen then DayOpen + ATR else PD_Close + ATR;
#plot latr = if atrLinesFrom  == atrLinesFrom .dayOpen then DayOpen - ATR else PD_Close - ATR;

#hatr.SetLineWeight(5);
#hatr.SetDefaultColor(Color.RED);
#hatr.SetStyle(Curve.LONG_DASH);
#hatr.HideBubble();
#hatr.HideTitle();
#hatr.SetHiding(showAtrLines == no);

#latr.SetLineWeight(5);
#latr.SetStyle(Curve.LONG_DASH);
#latr.SetDefaultColor(Color.GREEN);
#latr.HideBubble();
#latr.HideTitle();
#latr.SetHiding(showAtrLines == no);

#DefineGlobalColor("hatr", Color.PINK);
#AddChartBubble(ShowBubbles and showAtrLines and BubbleLocation, hatr, "ATRH: " + (if ShowPricesInBubbles then AsText(hatr) else ""), GlobalColor("hatr"));

#DefineGlobalColor("latr", Color.LIGHT_GREEN);
#AddChartBubble(ShowBubbles and showAtrLines and BubbleLocation, latr, "ATRL: " + (if ShowPricesInBubbles then AsText(latr) else ""), GlobalColor("latr"), no);
thank you!

The fib level that I was looking were 21.4, 23.6, 38.2, 50, 61.8, 76.4, 78.6, 100, 121.4, 123.6, 138.2, 150, 161.8, 176.4, 178.6, 200, 221.4, 223.6, 238.2, 250, 261.8, 278.6, 276.4, 423.6.

Fibs plotted in both directions:

Pre market high to low

And pre market low to high
 
Last edited:
Hi SleepyZ, can you please help to draw vertical line as dividend alert indicator on day before the dividend being paid?

Try this

Screenshot 2024-02-19 114531.png
Code:
def div = if GetDividend()[-1] then 1 else 0;
AddVerticalLine(div == 1, " ", Color.WHITE);

#
 
Hello can anyone change open on this from 1800 to 930 (like sleepy has it)? I like his version but I miss ATR and seeing multiple days. It's nice for futures, but I also like the ATR and how this one looks. Ty

Code:
# Previous Day High/Low/Close + Premarket High/Low + High/Low/Open of Day + ATR Lines
# Created by Wiinii
# V1.6
# Some code based on code by Mobius (premarket) and TraderKevin (ATR lines
# https://usethinkscript.com/threads/previous-day-high-low-close-premarket-high-low-high-low-open-of-day-for-thinkorswim.13139/

declare hide_on_daily;

input length = 1;
input showOnlyLastPeriod = yes;
input ShowBubbles = yes;
input locate_bubbles_at = {default Expansion, Time};
input locate_bubbles_at_time = 800;
input BarsFromExpansion = 1;
input ShowPricesInBubbles = yes;

def bn = BarNumber();
def na = Double.NaN;
def h  = high;
def l  = low;
def o = open;
def c = close;
def v = volume;
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];
}

PD_High.SetDefaultColor(Color.DARK_ORANGE);
PD_High.SetStyle(Curve.LONG_DASH);
PD_High.SetLineWeight(2);
PD_High.HideTitle();

PD_Low.SetDefaultColor(Color.DARK_ORANGE);
PD_Low.SetStyle(Curve.LONG_DASH);
PD_Low.SetLineWeight(2);
PD_Low.HideTitle();

PD_Close.SetDefaultColor(Color.WHITE);
PD_Close.SetStyle(Curve.LONG_DASH);
PD_Close.SetLineWeight(2);
PD_Close.HideTitle();

DefineGlobalColor("PD_High", CreateColor(255, 204, 153));
AddChartBubble(ShowBubbles and BubbleLocation, PD_High, "PDH: " + (if ShowPricesInBubbles then AsText(PD_High) else ""), GlobalColor("PD_High"));

DefineGlobalColor("PD_Low", CreateColor(255, 204, 153));
AddChartBubble(ShowBubbles and BubbleLocation, PD_Low, "PDL: " + (if ShowPricesInBubbles then AsText(PD_Low) else ""), GlobalColor("PD_Low"), no);

DefineGlobalColor("PD_Close", Color.WHITE);
AddChartBubble(ShowBubbles and BubbleLocation, PD_Close, "PDC: " + (if ShowPricesInBubbles then AsText(PD_Close) else ""), GlobalColor("PD_Close"));

PD_High.HideBubble();
PD_Low.HideBubble();
PD_Close.HideBubble();


#----- Premarket High/Low -----# Thanks to Mobius

def GlobeX = GetTime() < RegularTradingStart(GetYYYYMMDD());

def vol = if GlobeX and !GlobeX[1]
then v
else if GlobeX
then vol[1] + v
else na;

def GlobeX_Volume = vol;

def ONhigh = if GlobeX and !GlobeX[1]
then h
else if GlobeX and
h > ONhigh[1]
then h
else ONhigh[1];

def ONhighBar = if GlobeX and h == ONhigh
then bn
else na;

def ONlow = if GlobeX and !GlobeX[1]
then l
else if GlobeX and
l < ONlow[1]
then l
else ONlow[1];

def ONlowBar = if GlobeX and l == ONlow
then bn
else na;

def OverNightHigh = if BarNumber() == HighestAll(ONhighBar)
then ONhigh
else OverNightHigh[1];

def OverNightLow = if BarNumber() == HighestAll(ONlowBar)
then ONlow
else OverNightLow[1];

plot PM_High;
plot PM_Low;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
    PM_High = na;
    PM_Low = na;
} else {
    PM_High = if OverNightHigh > 0 then OverNightHigh else na;
    PM_Low = if OverNightLow > 0 then OverNightLow else na;
}

#PM_High.SetHiding(!PlotOverNightExtremes);
PM_High.SetLineWeight(2);
PM_High.SetDefaultColor(Color.CYAN);
PM_High.SetStyle(Curve.LONG_DASH);
PM_High.HideBubble();
PM_High.HideTitle();

#PM_Low.SetHiding(!PlotOverNightExtremes);
PM_Low.SetStyle(Curve.LONG_DASH);
PM_Low.SetDefaultColor(Color.CYAN);
PM_Low.HideBubble();
PM_Low.HideTitle();

DefineGlobalColor("PM_High", CreateColor(102, 255, 255));
AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONhighBar else isExpansion and firstExpansionBar == BarsFromExpansion, PM_High, "PMH: " + (if ShowPricesInBubbles then AsText(PM_High) else ""), GlobalColor("PM_High"));

DefineGlobalColor("PM_Low", CreateColor(102, 255, 255));
AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONlowBar else isExpansion and firstExpansionBar == BarsFromExpansion, PM_Low, "PML: " + (if ShowPricesInBubbles then AsText(PM_Low) else ""), GlobalColor("PM_Low"), no);


#----- Today Open/High/Low -----#


plot High_of_Day;
plot Low_of_Day;
plot DayOpen;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
    DayOpen = na;
    High_of_Day = na;
    Low_of_Day = na;
} else {
    DayOpen = open(period = aggregationPeriod)[0];
    High_of_Day = Highest(high(period = aggregationPeriod), length);
    Low_of_Day = Lowest(low(period = aggregationPeriod), length);
}

DayOpen.SetDefaultColor (Color.GRAY);
DayOpen.SetPaintingStrategy(PaintingStrategy.DASHES);
DayOpen.SetLineWeight(2);
DayOpen.HideTitle();

High_of_Day.SetDefaultColor(CreateColor(0, 128, 255));
High_of_Day.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
High_of_Day.SetLineWeight(2);
High_of_Day.HideTitle();

Low_of_Day.SetDefaultColor(CreateColor(0, 128, 255));
Low_of_Day.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Low_of_Day.SetLineWeight(2);
Low_of_Day.HideTitle();

DefineGlobalColor("Open", Color.LIGHT_GRAY);
AddChartBubble(ShowBubbles and BubbleLocation, DayOpen, "Open: " + (if ShowPricesInBubbles then AsText(DayOpen) else ""), GlobalColor("Open"));

DefineGlobalColor("High_of_Day", CreateColor(102, 178, 255));
AddChartBubble(ShowBubbles and BubbleLocation, High_of_Day, "HOD: " + (if ShowPricesInBubbles then AsText(High_of_Day) else ""), GlobalColor("High_of_Day"));

DefineGlobalColor("Low_of_Day", CreateColor(102, 178, 255));
AddChartBubble(ShowBubbles and BubbleLocation, Low_of_Day, "LOD: " + (if ShowPricesInBubbles then AsText(Low_of_Day) else ""), GlobalColor("Low_of_Day"), no);

#----- ATR Lines -----# Thaanks to TraderKevin
input showAtrLines = Yes;
input atrLinesFrom = {default pdc, dayOpen};
input ATRlength = 14;
input averageType = AverageType.WILDERS;

def ATR = MovingAverage(averageType, TrueRange(high(period = ”DAY”)[1], close(period = ”DAY”)[1], low(period = ”DAY”)[1]), ATRlength);

plot hatr = if atrLinesFrom  == atrLinesFrom .dayOpen then DayOpen + ATR else PD_Close + ATR;
plot latr = if atrLinesFrom  == atrLinesFrom .dayOpen then DayOpen - ATR else PD_Close - ATR;

hatr.SetLineWeight(5);
hatr.SetDefaultColor(Color.RED);
hatr.SetStyle(Curve.LONG_DASH);
hatr.HideBubble();
hatr.HideTitle();
hatr.SetHiding(showAtrLines == no);

latr.SetLineWeight(5);
latr.SetStyle(Curve.LONG_DASH);
latr.SetDefaultColor(Color.GREEN);
latr.HideBubble();
latr.HideTitle();
latr.SetHiding(showAtrLines == no);

DefineGlobalColor("hatr", Color.PINK);
AddChartBubble(ShowBubbles and showAtrLines and BubbleLocation, hatr, "ATRH: " + (if ShowPricesInBubbles then AsText(hatr) else ""), GlobalColor("hatr"));

DefineGlobalColor("latr", Color.LIGHT_GREEN);
AddChartBubble(ShowBubbles and showAtrLines and BubbleLocation, latr, "ATRL: " + (if ShowPricesInBubbles then AsText(latr) else ""), GlobalColor("latr"), no);
 
Last edited:
I looked around for a script with all the things and didn't see one, so I made one. You can change the colors and transparency of the bubbles under Globals as seen in 2nd pic, adjust the bubbles position to a specific time, and there is an option to turn off the bubbles altogether. By default the previous day's stuff is dashes, today's stuff is solid (but you can of course customize it all). You can also turn on the option to see previous days' stuff too. Enjoy!

UPDATES (1.6 - 4/7/23):
  • Now includes ATR projected move lines! Option for from open or previous day close.
  • You can now choose to have the bubbles show at a time or in the expansion area! To see it in the expansion area, click on the gear above the chart > go to Time Axis and change the Expansion area to a number that keeps them off your charts (this will vary depending on timeframe and zoom level).
Shared Link: http://tos.mx/LkI7ww4 (or use code below). Click here for --> Easiest way to load shared links

View attachment 16296

View attachment 16297

Code:
# Previous Day High/Low/Close + Premarket High/Low + High/Low/Open of Day + ATR Lines
# Created by Wiinii
# V1.6
# Some code based on code by Mobius (premarket) and TraderKevin (ATR lines
# https://usethinkscript.com/threads/previous-day-high-low-close-premarket-high-low-high-low-open-of-day-for-thinkorswim.13139/

declare hide_on_daily;

input length = 1;
input showOnlyLastPeriod = yes;
input ShowBubbles = yes;
input locate_bubbles_at = {default Expansion, Time};
input locate_bubbles_at_time = 800;
input BarsFromExpansion = 1;
input ShowPricesInBubbles = yes;

def bn = BarNumber();
def na = Double.NaN;
def h  = high;
def l  = low;
def o = open;
def c = close;
def v = volume;
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];
}

PD_High.SetDefaultColor(Color.DARK_ORANGE);
PD_High.SetStyle(Curve.LONG_DASH);
PD_High.SetLineWeight(2);
PD_High.HideTitle();

PD_Low.SetDefaultColor(Color.DARK_ORANGE);
PD_Low.SetStyle(Curve.LONG_DASH);
PD_Low.SetLineWeight(2);
PD_Low.HideTitle();

PD_Close.SetDefaultColor(Color.WHITE);
PD_Close.SetStyle(Curve.LONG_DASH);
PD_Close.SetLineWeight(2);
PD_Close.HideTitle();

DefineGlobalColor("PD_High", CreateColor(255, 204, 153));
AddChartBubble(ShowBubbles and BubbleLocation, PD_High, "PDH: " + (if ShowPricesInBubbles then AsText(PD_High) else ""), GlobalColor("PD_High"));

DefineGlobalColor("PD_Low", CreateColor(255, 204, 153));
AddChartBubble(ShowBubbles and BubbleLocation, PD_Low, "PDL: " + (if ShowPricesInBubbles then AsText(PD_Low) else ""), GlobalColor("PD_Low"), no);

DefineGlobalColor("PD_Close", Color.WHITE);
AddChartBubble(ShowBubbles and BubbleLocation, PD_Close, "PDC: " + (if ShowPricesInBubbles then AsText(PD_Close) else ""), GlobalColor("PD_Close"));

PD_High.HideBubble();
PD_Low.HideBubble();
PD_Close.HideBubble();


#----- Premarket High/Low -----# Thanks to Mobius

def GlobeX = GetTime() < RegularTradingStart(GetYYYYMMDD());

def vol = if GlobeX and !GlobeX[1]
then v
else if GlobeX
then vol[1] + v
else na;

def GlobeX_Volume = vol;

def ONhigh = if GlobeX and !GlobeX[1]
then h
else if GlobeX and
h > ONhigh[1]
then h
else ONhigh[1];

def ONhighBar = if GlobeX and h == ONhigh
then bn
else na;

def ONlow = if GlobeX and !GlobeX[1]
then l
else if GlobeX and
l < ONlow[1]
then l
else ONlow[1];

def ONlowBar = if GlobeX and l == ONlow
then bn
else na;

def OverNightHigh = if BarNumber() == HighestAll(ONhighBar)
then ONhigh
else OverNightHigh[1];

def OverNightLow = if BarNumber() == HighestAll(ONlowBar)
then ONlow
else OverNightLow[1];

plot PM_High;
plot PM_Low;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
    PM_High = na;
    PM_Low = na;
} else {
    PM_High = if OverNightHigh > 0 then OverNightHigh else na;
    PM_Low = if OverNightLow > 0 then OverNightLow else na;
}

#PM_High.SetHiding(!PlotOverNightExtremes);
PM_High.SetLineWeight(2);
PM_High.SetDefaultColor(Color.CYAN);
PM_High.SetStyle(Curve.LONG_DASH);
PM_High.HideBubble();
PM_High.HideTitle();

#PM_Low.SetHiding(!PlotOverNightExtremes);
PM_Low.SetStyle(Curve.LONG_DASH);
PM_Low.SetDefaultColor(Color.CYAN);
PM_Low.HideBubble();
PM_Low.HideTitle();

DefineGlobalColor("PM_High", CreateColor(102, 255, 255));
AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONhighBar else isExpansion and firstExpansionBar == BarsFromExpansion, PM_High, "PMH: " + (if ShowPricesInBubbles then AsText(PM_High) else ""), GlobalColor("PM_High"));

DefineGlobalColor("PM_Low", CreateColor(102, 255, 255));
AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONlowBar else isExpansion and firstExpansionBar == BarsFromExpansion, PM_Low, "PML: " + (if ShowPricesInBubbles then AsText(PM_Low) else ""), GlobalColor("PM_Low"), no);


#----- Today Open/High/Low -----#


plot High_of_Day;
plot Low_of_Day;
plot DayOpen;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
    DayOpen = na;
    High_of_Day = na;
    Low_of_Day = na;
} else {
    DayOpen = open(period = aggregationPeriod)[0];
    High_of_Day = Highest(high(period = aggregationPeriod), length);
    Low_of_Day = Lowest(low(period = aggregationPeriod), length);
}

DayOpen.SetDefaultColor (Color.GRAY);
DayOpen.SetPaintingStrategy(PaintingStrategy.DASHES);
DayOpen.SetLineWeight(2);
DayOpen.HideTitle();

High_of_Day.SetDefaultColor(CreateColor(0, 128, 255));
High_of_Day.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
High_of_Day.SetLineWeight(2);
High_of_Day.HideTitle();

Low_of_Day.SetDefaultColor(CreateColor(0, 128, 255));
Low_of_Day.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Low_of_Day.SetLineWeight(2);
Low_of_Day.HideTitle();

DefineGlobalColor("Open", Color.LIGHT_GRAY);
AddChartBubble(ShowBubbles and BubbleLocation, DayOpen, "Open: " + (if ShowPricesInBubbles then AsText(DayOpen) else ""), GlobalColor("Open"));

DefineGlobalColor("High_of_Day", CreateColor(102, 178, 255));
AddChartBubble(ShowBubbles and BubbleLocation, High_of_Day, "HOD: " + (if ShowPricesInBubbles then AsText(High_of_Day) else ""), GlobalColor("High_of_Day"));

DefineGlobalColor("Low_of_Day", CreateColor(102, 178, 255));
AddChartBubble(ShowBubbles and BubbleLocation, Low_of_Day, "LOD: " + (if ShowPricesInBubbles then AsText(Low_of_Day) else ""), GlobalColor("Low_of_Day"), no);

#----- ATR Lines -----# Thaanks to TraderKevin
input showAtrLines = Yes;
input atrLinesFrom = {default pdc, dayOpen};
input ATRlength = 14;
input averageType = AverageType.WILDERS;

def ATR = MovingAverage(averageType, TrueRange(high(period = ”DAY”)[1], close(period = ”DAY”)[1], low(period = ”DAY”)[1]), ATRlength);

plot hatr = if atrLinesFrom  == atrLinesFrom .dayOpen then DayOpen + ATR else PD_Close + ATR;
plot latr = if atrLinesFrom  == atrLinesFrom .dayOpen then DayOpen - ATR else PD_Close - ATR;

hatr.SetLineWeight(5);
hatr.SetDefaultColor(Color.RED);
hatr.SetStyle(Curve.LONG_DASH);
hatr.HideBubble();
hatr.HideTitle();
hatr.SetHiding(showAtrLines == no);

latr.SetLineWeight(5);
latr.SetStyle(Curve.LONG_DASH);
latr.SetDefaultColor(Color.GREEN);
latr.HideBubble();
latr.HideTitle();
latr.SetHiding(showAtrLines == no);

DefineGlobalColor("hatr", Color.PINK);
AddChartBubble(ShowBubbles and showAtrLines and BubbleLocation, hatr, "ATRH: " + (if ShowPricesInBubbles then AsText(hatr) else ""), GlobalColor("hatr"));

DefineGlobalColor("latr", Color.LIGHT_GREEN);
AddChartBubble(ShowBubbles and showAtrLines and BubbleLocation, latr, "ATRL: " + (if ShowPricesInBubbles then AsText(latr) else ""), GlobalColor("latr"), no);
Hi,
I want to list all tickers in my WL that breaks down previous day high or low. When I use above code, scan fails with message: Secondary period not allowed: Day.

1708981685104.png


please help to resolve this scan issue
 
Appreciate someone can help How to scan the indicator for example like to scan price crosses above the low of the day, Also is there a watchlist column to show if the current candle higher than low of the day or high of the day, Thanks a bunch in advance,
 
Last edited:
I looked around for a script with all the things and didn't see one, so I made one. You can change the colors and transparency of the bubbles under Globals as seen in 2nd pic, adjust the bubbles position to a specific time, and there is an option to turn off the bubbles altogether. By default the previous day's stuff is dashes, today's stuff is solid (but you can of course customize it all). You can also turn on the option to see previous days' stuff too. Enjoy!

UPDATES (1.6 - 4/7/23):
  • Now includes ATR projected move lines! Option for from open or previous day close.
  • You can now choose to have the bubbles show at a time or in the expansion area! To see it in the expansion area, click on the gear above the chart > go to Time Axis and change the Expansion area to a number that keeps them off your charts (this will vary depending on timeframe and zoom level).
Shared Link: http://tos.mx/LkI7ww4 (or use code below). Click here for --> Easiest way to load shared links

View attachment 16296

View attachment 16297

Code:
# Previous Day High/Low/Close + Premarket High/Low + High/Low/Open of Day + ATR Lines
# Created by Wiinii
# V1.6
# Some code based on code by Mobius (premarket) and TraderKevin (ATR lines
# https://usethinkscript.com/threads/previous-day-high-low-close-premarket-high-low-high-low-open-of-day-for-thinkorswim.13139/

declare hide_on_daily;

input length = 1;
input showOnlyLastPeriod = yes;
input ShowBubbles = yes;
input locate_bubbles_at = {default Expansion, Time};
input locate_bubbles_at_time = 800;
input BarsFromExpansion = 1;
input ShowPricesInBubbles = yes;

def bn = BarNumber();
def na = Double.NaN;
def h  = high;
def l  = low;
def o = open;
def c = close;
def v = volume;
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];
}

PD_High.SetDefaultColor(Color.DARK_ORANGE);
PD_High.SetStyle(Curve.LONG_DASH);
PD_High.SetLineWeight(2);
PD_High.HideTitle();

PD_Low.SetDefaultColor(Color.DARK_ORANGE);
PD_Low.SetStyle(Curve.LONG_DASH);
PD_Low.SetLineWeight(2);
PD_Low.HideTitle();

PD_Close.SetDefaultColor(Color.WHITE);
PD_Close.SetStyle(Curve.LONG_DASH);
PD_Close.SetLineWeight(2);
PD_Close.HideTitle();

DefineGlobalColor("PD_High", CreateColor(255, 204, 153));
AddChartBubble(ShowBubbles and BubbleLocation, PD_High, "PDH: " + (if ShowPricesInBubbles then AsText(PD_High) else ""), GlobalColor("PD_High"));

DefineGlobalColor("PD_Low", CreateColor(255, 204, 153));
AddChartBubble(ShowBubbles and BubbleLocation, PD_Low, "PDL: " + (if ShowPricesInBubbles then AsText(PD_Low) else ""), GlobalColor("PD_Low"), no);

DefineGlobalColor("PD_Close", Color.WHITE);
AddChartBubble(ShowBubbles and BubbleLocation, PD_Close, "PDC: " + (if ShowPricesInBubbles then AsText(PD_Close) else ""), GlobalColor("PD_Close"));

PD_High.HideBubble();
PD_Low.HideBubble();
PD_Close.HideBubble();


#----- Premarket High/Low -----# Thanks to Mobius

def GlobeX = GetTime() < RegularTradingStart(GetYYYYMMDD());

def vol = if GlobeX and !GlobeX[1]
then v
else if GlobeX
then vol[1] + v
else na;

def GlobeX_Volume = vol;

def ONhigh = if GlobeX and !GlobeX[1]
then h
else if GlobeX and
h > ONhigh[1]
then h
else ONhigh[1];

def ONhighBar = if GlobeX and h == ONhigh
then bn
else na;

def ONlow = if GlobeX and !GlobeX[1]
then l
else if GlobeX and
l < ONlow[1]
then l
else ONlow[1];

def ONlowBar = if GlobeX and l == ONlow
then bn
else na;

def OverNightHigh = if BarNumber() == HighestAll(ONhighBar)
then ONhigh
else OverNightHigh[1];

def OverNightLow = if BarNumber() == HighestAll(ONlowBar)
then ONlow
else OverNightLow[1];

plot PM_High;
plot PM_Low;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
    PM_High = na;
    PM_Low = na;
} else {
    PM_High = if OverNightHigh > 0 then OverNightHigh else na;
    PM_Low = if OverNightLow > 0 then OverNightLow else na;
}

#PM_High.SetHiding(!PlotOverNightExtremes);
PM_High.SetLineWeight(2);
PM_High.SetDefaultColor(Color.CYAN);
PM_High.SetStyle(Curve.LONG_DASH);
PM_High.HideBubble();
PM_High.HideTitle();

#PM_Low.SetHiding(!PlotOverNightExtremes);
PM_Low.SetStyle(Curve.LONG_DASH);
PM_Low.SetDefaultColor(Color.CYAN);
PM_Low.HideBubble();
PM_Low.HideTitle();

DefineGlobalColor("PM_High", CreateColor(102, 255, 255));
AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONhighBar else isExpansion and firstExpansionBar == BarsFromExpansion, PM_High, "PMH: " + (if ShowPricesInBubbles then AsText(PM_High) else ""), GlobalColor("PM_High"));

DefineGlobalColor("PM_Low", CreateColor(102, 255, 255));
AddChartBubble(ShowBubbles and if locate_bubbles_at == locate_bubbles_at.Time then bn == ONlowBar else isExpansion and firstExpansionBar == BarsFromExpansion, PM_Low, "PML: " + (if ShowPricesInBubbles then AsText(PM_Low) else ""), GlobalColor("PM_Low"), no);


#----- Today Open/High/Low -----#


plot High_of_Day;
plot Low_of_Day;
plot DayOpen;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
    DayOpen = na;
    High_of_Day = na;
    Low_of_Day = na;
} else {
    DayOpen = open(period = aggregationPeriod)[0];
    High_of_Day = Highest(high(period = aggregationPeriod), length);
    Low_of_Day = Lowest(low(period = aggregationPeriod), length);
}

DayOpen.SetDefaultColor (Color.GRAY);
DayOpen.SetPaintingStrategy(PaintingStrategy.DASHES);
DayOpen.SetLineWeight(2);
DayOpen.HideTitle();

High_of_Day.SetDefaultColor(CreateColor(0, 128, 255));
High_of_Day.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
High_of_Day.SetLineWeight(2);
High_of_Day.HideTitle();

Low_of_Day.SetDefaultColor(CreateColor(0, 128, 255));
Low_of_Day.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Low_of_Day.SetLineWeight(2);
Low_of_Day.HideTitle();

DefineGlobalColor("Open", Color.LIGHT_GRAY);
AddChartBubble(ShowBubbles and BubbleLocation, DayOpen, "Open: " + (if ShowPricesInBubbles then AsText(DayOpen) else ""), GlobalColor("Open"));

DefineGlobalColor("High_of_Day", CreateColor(102, 178, 255));
AddChartBubble(ShowBubbles and BubbleLocation, High_of_Day, "HOD: " + (if ShowPricesInBubbles then AsText(High_of_Day) else ""), GlobalColor("High_of_Day"));

DefineGlobalColor("Low_of_Day", CreateColor(102, 178, 255));
AddChartBubble(ShowBubbles and BubbleLocation, Low_of_Day, "LOD: " + (if ShowPricesInBubbles then AsText(Low_of_Day) else ""), GlobalColor("Low_of_Day"), no);

#----- ATR Lines -----# Thaanks to TraderKevin
input showAtrLines = Yes;
input atrLinesFrom = {default pdc, dayOpen};
input ATRlength = 14;
input averageType = AverageType.WILDERS;

def ATR = MovingAverage(averageType, TrueRange(high(period = ”DAY”)[1], close(period = ”DAY”)[1], low(period = ”DAY”)[1]), ATRlength);

plot hatr = if atrLinesFrom  == atrLinesFrom .dayOpen then DayOpen + ATR else PD_Close + ATR;
plot latr = if atrLinesFrom  == atrLinesFrom .dayOpen then DayOpen - ATR else PD_Close - ATR;

hatr.SetLineWeight(5);
hatr.SetDefaultColor(Color.RED);
hatr.SetStyle(Curve.LONG_DASH);
hatr.HideBubble();
hatr.HideTitle();
hatr.SetHiding(showAtrLines == no);

latr.SetLineWeight(5);
latr.SetStyle(Curve.LONG_DASH);
latr.SetDefaultColor(Color.GREEN);
latr.HideBubble();
latr.HideTitle();
latr.SetHiding(showAtrLines == no);

DefineGlobalColor("hatr", Color.PINK);
AddChartBubble(ShowBubbles and showAtrLines and BubbleLocation, hatr, "ATRH: " + (if ShowPricesInBubbles then AsText(hatr) else ""), GlobalColor("hatr"));

DefineGlobalColor("latr", Color.LIGHT_GREEN);
AddChartBubble(ShowBubbles and showAtrLines and BubbleLocation, latr, "ATRL: " + (if ShowPricesInBubbles then AsText(latr) else ""), GlobalColor("latr"), no);

I noticed that the PM_High and PM_Low do not show up on any days except on the current day, even when show today only is "no".

Do you have a solution for this?

Thank you,
Mitch
 
Thank you for this indicator, it has been working well.

Is there a way to add the bubbles that appear on the lines you have to a couple of EMA indicators that I have?
I have the 8 and 21 daily ema on the intraday. It would be great to add the bubbles on that line that remind me what it is and the value of it.

This is the code from the indicator.

plot Data = close;
# MTF Moving Average

input Period = aggregationPeriod.DAY;
input AvgType = averageType.EXPONENTIAL;
input Length =8;
input priceclose = close;

plot AVG = MovingAverage(AvgType, close(period = Period), Length);
AVG.setdefaultcolor(color.GREEN);
 

Attachments

  • Screenshot 2024-03-23 183520.png
    Screenshot 2024-03-23 183520.png
    4.9 KB · Views: 38
I would greatly appreciate it if someone could make the color of the bubbles match the individual horizontal line of the color. for example,

PMH bubble Dark Orange and line Dark orange.

HOD Bubble and Line Red

OPEN bubble green and line green

Awesome script thus far, and thank you to those that have created and contributed to it
 

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
322 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