# Cloud above or below stock's opening price?

#### evanevans

##### Active member
Is there an indicator to show a green or red cloud above or below the open price on charts? This is the closest thing I can find that has some resemblance to what I'm talking about:

But the difference would be that on mine, the negative periods would be red cloud, and the positive periods green cloud.

Last edited by a moderator:

#### Pensar

##### Well-known member
VIP
@evanevans Here is something simple; it will only display during regular trading hours.

Code:
``````declare hide_on_daily;
def start = if SecondsFromTime(0930) >= 0 then 1 else 0;
def end = if SecondsTillTime(1600) >= 0 then 1 else 0;
def o = open(period = aggregationperiod.day);
plot pivot = if start and end then o else double.nan;
def above = if low > o then hl2 else double.nan;
def below = if high < o then hl2 else double.nan;

#### evanevans

##### Active member
Yes sir. That looks great.

#### JoeSD

##### Member
@evanevans Here is something simple; it will only display during regular trading hours.

Code:
``````declare hide_on_daily;
def start = if SecondsFromTime(0930) >= 0 then 1 else 0;
def end = if SecondsTillTime(1600) >= 0 then 1 else 0;
def o = open(period = aggregationperiod.day);
plot pivot = if start and end then o else double.nan;
def above = if low > o then hl2 else double.nan;
def below = if high < o then hl2 else double.nan;
Pensar, I saw this code (I am by no means a coder...) and wondered if there would be a way to have automatically have a horizontal line from both the top and bottom of the trading start opening bar. I would want to put it on maybe a 2M and 5M chat. Thanks.

Joe

#### Pensar

##### Well-known member
VIP
Pensar, I saw this code (I am by no means a coder...) and wondered if there would be a way to have automatically have a horizontal line from both the top and bottom of the trading start opening bar. I would want to put it on maybe a 2M and 5M chat. Thanks.

Joe
@JoeSD Yes, this can be done. Have you already looked at the Opening Range Breakout indicators on this site? There are some simple ones here that can easily do what you ask - all that should be necessary is to adjust the input times. If you search and find something that you need help with, post what you need in the respective thread.

#### JoeSD

##### Member
@JoeSD Yes, this can be done. Have you already looked at the Opening Range Breakout indicators on this site? There are some simple ones here that can easily do what you ask - all that should be necessary is to adjust the input times. If you search and find something that you need help with, post what you need in the respective thread.
Pensar, yes, I did look through everything and did not find anything that I was able to use... Actually, what would be even better is this:

1. If the opening bar was GREEN, then have only a horizontal line from that point the highest part of the candle.

2. If the opening bar was red, then only a horizontal line from the lowest part of the candle.

Thanks.

Joe

#### halcyonguy

##### Well-known member
VIP
Pensar, yes, I did look through everything and did not find anything that I was able to use... Actually, what would be even better is this:

1. If the opening bar was GREEN, then have only a horizontal line from that point the highest part of the candle.

2. If the opening bar was red, then only a horizontal line from the lowest part of the candle.

Thanks.

Joe
sometimes you won't find exactly what you are looking for on this site, but there is a good chance that you will find something close. to say you found nothing, when others know there to be what was suggested, makes you look lazy, and may cause others to ignore your post. maybe you don't know how to modify what you found?

use the link below, look at some of the chart images . when you find a post that is close to what you want, click on the post #, then copy the web link and paste it in a comment ( with tags),
how do i modify this... to do this.....

when i searched on this site for orb, it showed 0 results at the top. word too short. but below that were pages of results that google found on the site.

#### JoeSD

##### Member
sometimes you won't find exactly what you are looking for on this site, but there is a good chance that you will find something close. to say you found nothing, when others know there to be what was suggested, makes you look lazy, and may cause others to ignore your post. maybe you don't know how to modify what you found?

use the link below, look at some of the chart images . when you find a post that is close to what you want, click on the post #, then copy the web link and paste it in a comment ( with tags),
how do i modify this... to do this.....

when i searched on this site for orb, it showed 0 results at the top. word too short. but below that were pages of results that google found on the site.

@Hlcyonguy - thanks for the reply. I try to do my homework ahead of time but my issue is I have 0 coding ability so even if I find something close can't do much with it.

#### halcyonguy

##### Well-known member
VIP
@Hlcyonguy - thanks for the reply. I try to do my homework ahead of time but my issue is I have 0 coding ability so even if I find something close can't do much with it.
that's ok , we were all beginners at one time. just ask questions.

#### halcyonguy

##### Well-known member
VIP
Pensar, yes, I did look through everything and did not find anything that I was able to use... Actually, what would be even better is this:

1. If the opening bar was GREEN, then have only a horizontal line from that point the highest part of the candle.

2. If the opening bar was red, then only a horizontal line from the lowest part of the candle.

Thanks.

Joe
today, i will look over my notes and make a study to do this.

#### JoeSD

##### Member
today, i will look over my notes and make a study to do this.
Thank you

#### SleepyZ

##### Well-known member
VIP
Pensar, yes, I did look through everything and did not find anything that I was able to use... Actually, what would be even better is this:

1. If the opening bar was GREEN, then have only a horizontal line from that point the highest part of the candle.

2. If the opening bar was red, then only a horizontal line from the lowest part of the candle.

Thanks.

Joe

See if this helps

Code:
``````def o  = if GetTime() crosses above RegularTradingStart(GetYYYYMMDD()) then 1 else 0;
def oh = if o == 1 and close > open then high else oh[1];
def ol = if o == 1 and open > close then low  else ol[1];
plot ohigh = oh;
plot olow  = ol;
ohigh.SetDefaultColor(Color.GREEN);
olow.SetDefaultColor(Color.RED);``````

#### halcyonguy

##### Well-known member
VIP
See if this helps

Code:
``````def o  = if GetTime() crosses above RegularTradingStart(GetYYYYMMDD()) then 1 else 0;
def oh = if o == 1 and close > open then high else oh[1];
def ol = if o == 1 and open > close then low  else ol[1];
plot ohigh = oh;
plot olow  = ol;
ohigh.SetDefaultColor(Color.GREEN);
olow.SetDefaultColor(Color.RED);``````

@SleepyZ thanks for sharing, that is a creative use of 'crosses' in that logic.

on my chart, i have to have to have extended hours displayed, for that code to show lines.

i added these 2 lines to force the lines to be horizontal (removes that vertical portion that conects the horizontal lines).
Code:
``````ohigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
olow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);``````

one strange thing, sometimes the lines don't show up.
using the symbol R , no lines are drawn on a 15m 5day chart. but on a 15m 20day, the lines show up.
not sure if it is because of few days, or the few candles in after hours, that are mostly 0 height.

#### halcyonguy

##### Well-known member
VIP
@Hlcyonguy - thanks for the reply. I try to do my homework ahead of time but my issue is I have 0 coding ability so even if I find something close can't do much with it.
here is another version. i started to look at some orb studies, but then remembered the code from a korygill study that finds the first and last bar of the day. i kept just the part related to finding the first bar. then i added sleeyz code to that and have the following. it seems to work with or without extended hours.

Ruby:
``````# firstbarlevels_01

# GetDayValues
# Author: Kory Gill, @korygill
#
# VERSION HISTORY (sortable date and time (your local time is fine), and your initials
# 20190823-1400-KG    - Created.
declare hide_on_daily;
declare once_per_bar;

def nan = Double.NaN;
def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
#def afterEnd = GetTime() > RegularTradingEnd(GetYYYYMMDD());
def firstBarOfDay = if (beforeStart[1] == 1 and beforeStart == 0) or (isRollover and beforeStart == 0) then 1 else 0;

# sleepyz code
def o =  firstBarOfDay;
def oh = if o == 1 and close > open then high else oh[1];
def ol = if o == 1 and open > close then low  else ol[1];
plot ohigh = oh;
plot olow  = ol;
ohigh.SetDefaultColor(Color.GREEN);
olow.SetDefaultColor(Color.RED);
ohigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
olow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
#``````

#### JoeSD

##### Member
@halcyonguy. @SleeyZ - thank you both. I will look them over.

#### Learnbot

##### Active member
Hello,
Is there a way to plot first 5 min candle high and low on 1 min chart, and this plot only start to plot during market open times?

Code:
``````declare hide_on_daily;
declare once_per_bar;
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 1 else 0;

Rec MOHigh = if MOHigh[1] == 0 or firstbarofday[1] == 0 AND firstbarofday == 1 then high else MOHigh[1];
Rec MOLow = if MOLow[1] == 0 or firstbarofday[1] == 0 AND firstbarofday == 1 then low else MOLow[1];

Plot High = mohigh;
plot low = molow;

Thank you,

Last edited:

## 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?