Painting Horizontal Clouds

Good afternoon. Below is a snippet of a script I use that paints a vertical cloud when a certain condition becomes true. I have spent quite a while trying to figure out how to get the cloud to paint horizontally, but have not had any luck. I have tried ChatGPT for this as well with no progress. Any clues would be appreciated on how to modify this code to populate a horizontal cloud when this condition becomes true!


### SYMMETRICAL INFINITY RANGES ###

def cond3 = (if((zscore > -0.01 and zscore < 0.01))

then double.positive_infinity
else double.negative_infinity);

AddCloud(if showclouds
then cond3
else Double.NaN,
double.negative_infinity,
Color.yellow, Color.yellow);
 
Solution
Thank you for your reply!

I would be okay with the cloud extending out until 17:00 for simplicity.
For complexity, I would like for the cloud to end when a new one begins (but it is not necessary)

The concept is also built to be analyzed on a 1m chart.


At the end of the day, I am trying to identify the correct candle. I feel like I am close, just can't put my finger on it.

this will draw a cloud when a trigger happens and continue until the end of day
i used a zscore study i had, not sure if it is the same one you mentioned.
new code added to the end of the zscore study

Code:
# zscore_rng_00

#https://usethinkscript.com/threads/painting-horizontal-clouds.14019/
#def cond3 = (if((zscore > -0.01 and zscore < 0.01))

#...
Good afternoon. Below is a snippet of a script I use that paints a vertical cloud when a certain condition becomes true. I have spent quite a while trying to figure out how to get the cloud to paint horizontally, but have not had any luck. I have tried ChatGPT for this as well with no progress. Any clues would be appreciated on how to modify this code to populate a horizontal cloud when this condition becomes true!


### SYMMETRICAL INFINITY RANGES ###

def cond3 = (if((zscore > -0.01 and zscore < 0.01))

then double.positive_infinity
else double.negative_infinity);

AddCloud(if showclouds
then cond3
else Double.NaN,
double.negative_infinity,
Color.yellow, Color.yellow);

to draw shapes 'horizontally' you need to set the time parameter to true.
for a cloud, need to have 2 valid price levels, for the duration of the desired cloud. so some condition will be true during the desired cloud period.

what does horizontal mean to you?
a period that is,
4 bars after a signal?
10 bars before to 10 bars after a signal?
covering all the periods with bars?
the whole chart?
 

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

to draw shapes 'horizontally' you need to set the time parameter to true.
for a cloud, need to have 2 valid price levels, for the duration of the desired cloud. so some condition will be true during the desired cloud period.

what does horizontal mean to you?
a period that is,
4 bars after a signal?
10 bars before to 10 bars after a signal?
covering all the periods with bars?
the whole chart?
Thank you for your reply!

I would be okay with the cloud extending out until 17:00 for simplicity.
For complexity, I would like for the cloud to end when a new one begins (but it is not necessary)

The concept is also built to be analyzed on a 1m chart.


At the end of the day, I am trying to identify the correct candle. I feel like I am close, just can't put my finger on it.
 
Thank you for your reply!

I would be okay with the cloud extending out until 17:00 for simplicity.
For complexity, I would like for the cloud to end when a new one begins (but it is not necessary)

The concept is also built to be analyzed on a 1m chart.


At the end of the day, I am trying to identify the correct candle. I feel like I am close, just can't put my finger on it.

this will draw a cloud when a trigger happens and continue until the end of day
i used a zscore study i had, not sure if it is the same one you mentioned.
new code added to the end of the zscore study

Code:
# zscore_rng_00

#https://usethinkscript.com/threads/painting-horizontal-clouds.14019/
#def cond3 = (if((zscore > -0.01 and zscore < 0.01))

# https://usethinkscript.com/threads/z-score-lower-indicator-modification-for-thinkorswim-plotting-a-z-score-for-a-composite-symbol-below-a-chart-of-the-ndx-nasdaq-100.6714/

declare lower;
input price = close;
input length = 20;
input ZavgLength = 20;

def oneSD = stdev(price,length);
def avgClose = simpleMovingAvg(price,length);
def ofoneSD = oneSD*price[1];
def Zscorevalue = ((price-avgClose)/oneSD);
def avgZv = average(Zscorevalue,20);

plot Zscore = ((price-avgClose)/oneSD);
Zscore.setPaintingStrategy(paintingStrategy.HISTOGRAM);
Zscore.setLineWeight(2);
Zscore.assignValueColor(if Zscore > 0 then color.dark_green else color.dark_green);
plot avgZscore = average(Zscorevalue,ZavgLength);
avgZscore.setPaintingStrategy(paintingStrategy.LINE);

plot zero = 0;
plot one = 1;
plot negone = -1;
plot two = 2;
plot negtwo = -2;
zero.setDefaultColor(color.black);

#-------------------------------

# add new code

def na = double.nan;
input end = 1600;

# stop cloud at end of day
def stop = if secondsfromTime(end) >= 0 then 1 else 0;
# check if a new day starts
def newday = getday() != getday()[1];

# set a condition to 1 if triggered
# if a newday , reset to 0
# if end of day, reset
# repeat previoius value, till end of day
def cond3 = if newday then 0
  else if stop then 0
  else if (zscore > -0.01 and zscore < 0.01) then 1
  else cond3[1];

# set top and bottom values for cloud
def top = if cond3 and !stop then double.positive_infinity else na;
def bot = double.negative_infinity;

# draw a cloud when a trigger occurs, and continue cloud for the remainder of the day
AddCloud(top , bot , Color.yellow, Color.yellow);
#

TR8WCqv.jpg
 
Solution
this will draw a cloud when a trigger happens and continue until the end of day
i used a zscore study i had, not sure if it is the same one you mentioned.
new code added to the end of the zscore study

Code:
# zscore_rng_00

#https://usethinkscript.com/threads/painting-horizontal-clouds.14019/
#def cond3 = (if((zscore > -0.01 and zscore < 0.01))

# https://usethinkscript.com/threads/z-score-lower-indicator-modification-for-thinkorswim-plotting-a-z-score-for-a-composite-symbol-below-a-chart-of-the-ndx-nasdaq-100.6714/

[QUOTE="halcyonguy, post: 116477, member: 10697"]
this will draw a cloud when a trigger happens and continue until the end of day
i used a zscore study i had, not sure if it is the same one you mentioned.
new code added to the end of the zscore study

[CODE]# zscore_rng_00

#https://usethinkscript.com/threads/painting-horizontal-clouds.14019/
#def cond3 = (if((zscore > -0.01 and zscore < 0.01))

# https://usethinkscript.com/threads/z-score-lower-indicator-modification-for-thinkorswim-plotting-a-z-score-for-a-composite-symbol-below-a-chart-of-the-ndx-nasdaq-100.6714/

declare lower;
input price = close;
input length = 20;
input ZavgLength = 20;

def oneSD = stdev(price,length);
def avgClose = simpleMovingAvg(price,length);
def ofoneSD = oneSD*price[1];
def Zscorevalue = ((price-avgClose)/oneSD);
def avgZv = average(Zscorevalue,20);

plot Zscore = ((price-avgClose)/oneSD);
Zscore.setPaintingStrategy(paintingStrategy.HISTOGRAM);
Zscore.setLineWeight(2);
Zscore.assignValueColor(if Zscore > 0 then color.dark_green else color.dark_green);
plot avgZscore = average(Zscorevalue,ZavgLength);
avgZscore.setPaintingStrategy(paintingStrategy.LINE);

plot zero = 0;
plot one = 1;
plot negone = -1;
plot two = 2;
plot negtwo = -2;
zero.setDefaultColor(color.black);

#-------------------------------

# add new code

def na = double.nan;
input end = 1600;

# stop cloud at end of day
def stop = if secondsfromTime(end) >= 0 then 1 else 0;
# check if a new day starts
def newday = getday() != getday()[1];

# set a condition to 1 if triggered
# if a newday , reset to 0
# if end of day, reset
# repeat previoius value, till end of day
def cond3 = if newday then 0
  else if stop then 0
  else if (zscore > -0.01 and zscore < 0.01) then 1
  else cond3[1];

# set top and bottom values for cloud
def top = if cond3 and !stop then double.positive_infinity else na;
def bot = double.negative_infinity;

# draw a cloud when a trigger occurs, and continue cloud for the remainder of the day
AddCloud(top , bot , Color.yellow, Color.yellow);
#

TR8WCqv.jpg


TR8WCqv.jpg

[/QUOTE]
Thank you so much for posting this! Logic is really well done!

Would there be anyway that the cloud could only paint a single 1m candle with an upper declaration? I loaded up the script and the cloud does paint horizontally just as needed, but the hope was to isolate the single 1m candles that meet that criteria (between -0.01 and 0.01).

Your time is much appreciated, I will also take a stab at modifying, but any further help would be greatly appreciated!!!!
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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