# High and Low of previous closing candle

#### jbennink83

##### New member
Hello, my dad uses a formula he came up with to watch his stocks. He has to manually do this every day. I have created a study that plots what he does however it tracks every candle and he just wants the Previous days closing candle high and low. At first i put used
# Previous Day Closing Price (PCL)
input aggregationPeriod = AggregationPeriod.DAY;
def close = close(period = aggregationPeriod)[1];
plot previous_close = close;
I pasted this twice and modified to show the high and close but that was not what he wanted. How can I get the high and low for the last candle of the previous day.
This is what i currently have at the moment:

# Previous Day Closing Price (PCL)
input aggregationPeriod = AggregationPeriod.DAY;
def close = close(period = aggregationPeriod)[1];
# Previous Day Closing Price (PCL)
input aggregationPeriod2 = AggregationPeriod.DAY;
def high = high (period = aggregationPeriod)[1];
def blue = close;
def green = ((high - close) * .8) + blue;
def yellow = ((green - blue) * .2) + blue;
def red = ((green - yellow) * .8) + blue;

plot theline = blue;
plot theline1 = green;
plot theline2 = yellow;
plot theline3 = red;

Hi - I am new to investing too. We're doing this for a class in school. So, I was so frustrated I started looking at the individual ticks and I've come up with a pattern after looking at hundreds of ticks that seems to prove out, I think for every candle. For example if you look at a specific candle it has a open, high, low, and close. (O) (H) (L) (C) When I looked at the specifics for each, I found out a pattern that can determine what the next candle is going to be before it shows up. For example if the (O) = x and the the (H), (L), and (C) = the same value then the next candle is going to be down. Also, if the (O) = x and the (H) = x, then both the (L) and the (C) will be < than (O). Opposite of this is when the stock is going up. If the (O) = x and the (H) > x, but the (L) = to the (O) x, then the (C) will be > (O) and the next candle is going up. I have more of these sequences written down and in each case when the (C) is equal to or less than the (O) the next candle will be down. My problem is that I am not a very good code writer but love to look at the detailed analysis. I think if you knew how to write the code and I could feed you more of these parameters maybe we could create some kind of key that will project the next tick and subsequent ticks by just the one previous tick, so that after two ticks we could see that a stock is going up and then we'd know what to do.

Thanks
Sincerely,
homeplate

Hi - I am new to investing too. We're doing this for a class in school. So, I was so frustrated I started looking at the individual ticks and I've come up with a pattern after looking at hundreds of ticks that seems to prove out, I think for every candle. For example if you look at a specific candle it has a open, high, low, and close. (O) (H) (L) (C) When I looked at the specifics for each, I found out a pattern that can determine what the next candle is going to be before it shows up. For example if the (O) = x and the the (H), (L), and (C) = the same value then the next candle is going to be down. Also, if the (O) = x and the (H) = x, then both the (L) and the (C) will be < than (O). Opposite of this is when the stock is going up. If the (O) = x and the (H) > x, but the (L) = to the (O) x, then the (C) will be > (O) and the next candle is going up. I have more of these sequences written down and in each case when the (C) is equal to or less than the (O) the next candle will be down. My problem is that I am not a very good code writer but love to look at the detailed analysis. I think if you knew how to write the code and I could feed you more of these parameters maybe we could create some kind of key that will project the next tick and subsequent ticks by just the one previous tick, so that after two ticks we could see that a stock is going up and then we'd know what to do.

Thanks
Sincerely,
homeplate
I have no problem helping with the code but I'm am new to code in TOS. I have written in other languages so I grasp what TOS is doing but still need to learn more to make more scripts. Once I know how to pick a specific candle and take the value of it then I could write a script for you.

if you have for example, a chart of 5 minute candles, and want to find data from the last bar of each day, then the following link will help.
it finds the first and last bar for each day.

with this, you could add logic to determine the desired day, and use data from just that day.

also, although it is possible to use Fundamental words such as close and high, as a variable name , it could be confusing to others. it might be better to add a descriptive word to the variable name, like prevclose = ....

https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Fundamentals

https://tlc.thinkorswim.com/center/reference/thinkScript/Reserved-Words

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