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

Related question! Can the regular trading hours be specified in the script, so that it can be used on futures charts?
Would love to see this revision as well, would it be possible to have previous day Open/High/Low separate from the over-night levels, and only track during RTH? Thanks again for throwing this together, you guys rock 🤟
 

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

Is there a way to stretch out the previous day high or low until price goes above the high or below the low? Like if the high of day for a stock on monday is $100 and then in two weeks time, price goes above that high, is there a way for the indicator to draw a line from monday's high until price revisits it and then it doesn't extend further?
 
Hey love this... but I don't want it on all day so I turn off the study, but the bubbles stay on the chart. Is that right? Thanks!
First of all try just moving the bubbles to a TIME, so if set to default 8am will be out of your way from open. Otherwise just use the option to turn off the bubbles.
 
Related question! Can the regular trading hours be specified in the script, so that it can be used on futures charts?

Would love to see this revision as well, would it be possible to have previous day Open/High/Low separate from the over-night levels, and only track during RTH? Thanks again for throwing this together, you guys rock 🤟

Futures don't open/close the same as stocks, so these are already calculated correctly.
 
Can someone let me know what code corrects the bubbles remaining on the screen despite unchecking "show plot" in the settings. There seems to be no way to hide the bubbles regardless of what is turned off.
 
@Wiinii
This is incredibly helpful big thank you!!
I've been trying to add an ADR (Average Daily Range) line in addition to the projected ATR line as it works better on day trade but couldn't get the codes to work, would you be able to help with that?

The code for ADR is:
input len = 20;
def ADR_perc = (Average(high, len) / Average(low, len) -1);

Thanks!
 
Last edited:
Can someone let me know what code corrects the bubbles remaining on the screen despite unchecking "show plot" in the settings. There seems to be no way to hide the bubbles regardless of what is turned off.
Put a # hashtag in front of all AddChartBubble statements in a script to remove the plotting of bubbles.
 
Is there anyway to draw the Premarket High/Low lines on every previous days?

Right now they're only appearing on the current day whereas the other lines shows up on previous days, this would help a ton with back test.
 
Weekly.high/Low, monthly high/low on current time frame that you viewing
@CashMoney: May I know if you were able to add Prior Week High/Low, Prior Month High/Low. If yes, could you please share the code?

Sure, PM_Mid added
@SleepyZ
For /MES futures,
1. the high of the day & low of the day ( blue line ) still keep showing in the pre-market, is it possible to show it only during RTH ( i.e from 9:00 AM EST ) ?
2. is it possible to extended the PM Mid, PM Low lines on the left side to the start of futures market i.e 6 PM EST
3. Can you include PD Mid ( Prior Day Midpoint as well ), also can lines ( PD High, PD Low, PD Mid ) be extended till prior day?
4. Appreciate if you can Please add Prior Week High, Low, Mid . Prior Month High, Low & Mid as well


http://tos.mx/apfF4Aj


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);
@Wiinii Only PDC, PDL and PDH are working for SPX. Is it possible to display ATR lines as well? It would be great if PWC , PWL & PWH ( Prior Week Close/High/Low ) are added as well

 
Last edited by a moderator:
Hi, I would like to thank Wiinii for sharing this indicator. However, I need help with this indicator on the FX charts. The bubbles only show 2 decimals.

I tried using AsText and NumberFormat.THREE_DECIMAL_PLACES, the best I can do is up to 3 decimals. I wonder why TOS only supports up to 3 decimals knowing that FX has up to 5 decimals.

Is there a way to display 4 to 5 decimals in the bubbles to show the FX pricing levels? Please help.

Thank you.
 
Futures don't open/close the same as stocks, so these are already calculated correctly.
#GapFill

def yesterdaysClose = close(period = "DAY")[1];
def secondsFromOpen = SecondsFromTime(930);
def secondsTillClose = SecondsTillTime(1600);<----------(I changed 16:15 to 1600 but script still prints GAP at 16:15, what I'm doing wrong???)
def marketOpen = if secondsFromOpen >= 0 and secondsTillClose >= 0 then 1 else 0;
rec regularHoursOpen = if (secondsFromOpen >= 0 and secondsFromOpen[1] < 0) or
(GetDay() != GetDay()[1]) then open else regularHoursOpen[1];
def newDay = if GetDay() != GetDay()[1] then 1 else 0;
rec regHoursHigh = if newDay then high else if marketOpen then if high > regHoursHigh[1] then high else regHoursHigh[1] else high;
rec regHoursLow = if newDay then low else if marketOpen then if low < regHoursLow[1] then low else regHoursLow[1] else low;
def yc = if marketOpen then yesterdaysClose else Double.NaN;
def o = if marketOpen then regularHoursOpen else Double.NaN;
def hg = o + (yc - o) / 2;
def gapUp = if yc < o then 1 else 0;
def gapDown = if yc > o then 1 else 0;
def gapRemaining = if gapUp then Max(regHoursLow - yc, 0) else
if gapDown then Max(yc - regHoursHigh, 0) else 0;
def percentRemaining = 100 * gapRemaining / AbsValue(yc - o);
def gapFilled = if percentRemaining == 0 then 1 else 0;
def halfGapFilled = if percentRemaining <= 50 then 1 else 0;
plot gH = if (gapUp and !gapFilled and marketOpen and !newDay[-1])
then regHoursLow else if (gapDown and !gapFilled and marketOpen and !newDay[-1])
then yc else Double.NaN;
plot gL = if (gapUp and !gapFilled and marketOpen and !newDay[-1])
then yc else if (gapDown and !gapFilled and marketOpen and !newDay[-1])
then regHoursHigh else Double.NaN;
plot hGF = if !gapFilled and !halfGapFilled and marketOpen and !newDay[-1]
then hg else Double.NaN;
gH.SetPaintingStrategy(PaintingStrategy.DASHES);
gH.AssignValueColor(if gapDown then Color.GREEN else Color.RED);
gL.SetPaintingStrategy(PaintingStrategy.DASHES);
gL.AssignValueColor(if gapDown then Color.GREEN else Color.RED);
AddCloud(gH, gL, Color.GRAY, Color.GRAY);
hGF.SetStyle(Curve.LONG_DASH);
hGF.SetDefaultColor(Color.DARK_GRAY);
gH.HideBubble();
gL.HideBubble();
hGF.HideBubble();
 
Is the a way to make the HOD and LOD to only work during open times instead of Pre-Market?
 
@Wiinii @samer800 @horserider @halcyonguy Can one of you please write this so we can only show market hours for Previous Day High and Previous Day Low? Maybe have an option to select. I have tried for a while now and have been unsuccessful. At this time this study will show Previous Days Premarket High and Pre Market Low for PDH and PDL. Thanks in advance. 🙏

Here is what I attempted to write and it doesn't work. Can someone help with this? or Is it possible to do?

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 marketOpen = SecondsFromTime(900) >= 0 and SecondsTillTime(1600) >= 0;
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 -----#

def PD_HighValue;
def PD_LowValue;
def PD_CloseValue;

if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
    PD_HighValue = na;
    PD_LowValue = na;
    PD_CloseValue = na;
} else {
    PD_HighValue = if marketOpen then Highest(high(period = aggregationPeriod)[-displace], length) else na;
    PD_LowValue = if marketOpen then Lowest(low(period = aggregationPeriod)[-displace], length) else na;
    PD_CloseValue = if marketOpen then close(period = aggregationPeriod)[-displace] else na;
}

plot PD_High = PD_HighValue;
plot PD_Low = PD_LowValue;
plot PD_Close = PD_CloseValue;

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:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
417 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