• Get $30 off VIP with code SUMMER30. Ends July 27. Happy trading!

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:

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

JoeSD

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;
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

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
VIP
@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

Active 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),
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.
 

JoeSD

Member
VIP
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.
 

halcyonguy

Active 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.
 

SleepyZ

Active member
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

Active 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

Active 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

# 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);
#
 

Similar threads

Top