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:

JdjMMc4.png


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:
@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;
AddCloud(above,pivot,color.dark_green,color.dark_green);
AddCloud(below,pivot,color.dark_red,color.dark_red);
 

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

@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;
AddCloud(above,pivot,color.dark_green,color.dark_green);
AddCloud(below,pivot,color.dark_red,color.dark_red);
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, 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 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
 
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),
and ask ,
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.

https://usethinkscript.com/google-s...words+were+too+short,+too+long,+or+too+common.
 
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),
and ask ,
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.

https://usethinkscript.com/google-search/?q=orb&tryAnyways=1&h=Forum+could+not+perform+a+search!&b=The+search+could+not+be+completed+because+the+search+keywords+were+too+short,+too+long,+or+too+common.
@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.
 
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.
 
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);
 
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.
 
@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

# https://usethinkscript.com/threads/finding-the-first-and-last-bar-of-the-day-in-thinkorswim.526/
# 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
# https://usethinkscript.com/threads/cloud-above-or-below-stocks-opening-price.3608/#post-69326
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);
#
 
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;
addcloud(high,low, color.gray,color.gray);

Thank you,
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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