# My code isn't working to get yesterday's highest high on 30 minute Watchlist column

#### greco26

##### Active member
HI,

I'm trying to return the value of yesterday's highest high but on a 30 minute watchlist column. The code below returns a high from yesterday but not the highest high for the entire day. Any thoughts on what I'm doing wrong?

Code:
``````def yesthi = if getday() then highest(high) else yesthi[1];

Solution
HI,

I'm trying to return the value of yesterday's highest high but on a 30 minute watchlist column. The code below returns a high from yesterday but not the highest high for the entire day. Any thoughts on what I'm doing wrong?

Code:
``````def yesthi = if getday() then highest(high) else yesthi[1];

regarding this line,
def yesthi = if getday() then highest(high) else yesthi[1];

for this to work, the condition would have to be true on the first bar of today, and the correct length in highest(). ( but the length will need to be different, depending on what the chart time is, and you can't use a complex formula for a length).

...getday() returns the day number of the year. it is not a...
HI,

I'm trying to return the value of yesterday's highest high but on a 30 minute watchlist column. The code below returns a high from yesterday but not the highest high for the entire day. Any thoughts on what I'm doing wrong?

Code:
``````def yesthi = if getday() then highest(high) else yesthi[1];

regarding this line,
def yesthi = if getday() then highest(high) else yesthi[1];

for this to work, the condition would have to be true on the first bar of today, and the correct length in highest(). ( but the length will need to be different, depending on what the chart time is, and you can't use a complex formula for a length).

...getday() returns the day number of the year. it is not a true/false condition.
it is never 0, so i think it might be always interpreted as true.

add this to a chart study to see the day numbers of the year.

...highest() expects to have a length, how many bars to look at.
if the length is missing, the default is 12. which will not be the correct amount to look at yesterday.

https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Date---Time/GetDay
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Tech-Analysis/Highest

----------------------------

this will work in a column, to get 1 of 4 stats from yesterday. open, high, low, or close.
there are plots and labels, because i tested it on a chart, before testing in a column.

the high plot is the only output line that is not commented out.
if a different stat is desired, add a # to plot zh = yhigh; and remove # from another plot.

this is roberts' code, from here

Ruby:
``````def today = GetDay() == GetLastDay();
def mktOpen = SecondsFromTime(0930) == 0 or GetDay() <> GetDay()[1];

def yOpen = if today then yOpen[1] else if mktOpen then open else yOpen[1]; #yesterday's open
def yHigh = if today then yHigh[1] else if mktOpen then high else if high > yHigh[1] then high else yHigh[1]; #yesterday's high
def yLow = if today then yLow[1] else if mktOpen then low else if low < yLow[1] then low else yLow[1]; #yesterday's low
def yClose = if today then yClose[1] else close; #yesterday's close

#plot zo = yopen;
plot zh = yhigh;
#plot zl = ylow;
#plot zc = yclose;

#addlabel(1, "yest open: " + yopen, color.yellow);
#addlabel(1, "yest high: " + yhigh, color.yellow);
#addlabel(1, "yest low: " + ylow, color.yellow);
#addlabel(1, "yest close: " + yclose, color.yellow);
#``````

Last edited:
@halcyonguy , my theory is that T below should return the highest high for today but it doesn't look like I'm getting that. Do you happen to see what I'm doing wrong? Thank you as always!!

def H = high;
def L = low;
def C = close;
def O = open;
def bn = barnumber();

def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def firstBarOfDay = if (beforeStart[1] == 1 and beforeStart == 0) or (isRollover and beforeStart == 0) then bn else firstBarOfDay[1];

def t = if bn >= firstbarofday and high >= highest(high) then high else t[1];

@halcyonguy , my theory is that T below should return the highest high for today but it doesn't look like I'm getting that. Do you happen to see what I'm doing wrong? Thank you as always!!

def H = high;
def L = low;
def C = close;
def O = open;
def bn = barnumber();

def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def firstBarOfDay = if (beforeStart[1] == 1 and beforeStart == 0) or (isRollover and beforeStart == 0) then bn else firstBarOfDay[1];

def t = if bn >= firstbarofday and high >= highest(high) then high else t[1];

just staring at the code....

have you tried turning on extended hours?

if extended hours is off,
i think beforeStart will never be true.
i think isRollover can determine the 1st bar

just staring at the code....

have you tried turning on extended hours?

if extended hours is off,
i think beforeStart will never be true.
i think isRollover can determine the 1st bar
Yea I tried turning extended hours on within the watchlist column but it returns the same data....

87k+ Posts
290 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?