Paint a cloud between specified price ranges

zeek

Active member
2019 Donor
Hi guys, i am looking for a study that does two things,

1. First, i want to paint a horizontal cloud between a specified price range with a low and high price and i want this cloud to stretch over the entire chart (on the selected timeframe & length) with input options to change the high & low price(s) and also the color of the cloud. And i need at least two of these price ranges in the study so that i can add more ranges later if i want to.

2. Secondly, an alert when price crosses into the cloud but only from below, not from above. Audio and a chartlabel that paints red when inside the cloud, otherwise paints gray.

So here´s an example of how this would look, in the first price range i used a low price of 11.00 and high price 11.05 and in the second range i used low price 11.25 and high price 11.30


I tried asking ChatGPT to write such a study but it wasn´t able to help with this and gave multiple errors. Appreciate if anyone can help with this.
 

halcyonguy

Well-known member
VIP
Lifetime
Hi guys, i am looking for a study that does two things,

1. First, i want to paint a horizontal cloud between a specified price range with a low and high price and i want this cloud to stretch over the entire chart (on the selected timeframe & length) with input options to change the high & low price(s) and also the color of the cloud. And i need at least two of these price ranges in the study so that i can add more ranges later if i want to.

2. Secondly, an alert when price crosses into the cloud but only from below, not from above. Audio and a chartlabel that paints red when inside the cloud, otherwise paints gray.

So here´s an example of how this would look, in the first price range i used a low price of 11.00 and high price 11.05 and in the second range i used low price 11.25 and high price 11.30


I tried asking ChatGPT to write such a study but it wasn´t able to help with this and gave multiple errors. Appreciate if anyone can help with this.

i'm going to do something different and not just provide an answer and ask others go along with this.
i'm going to guess you want to know how to do this, but are stuck on where to start.
i (we) will ask some questions, with the hope of you creating this study.

you have been around since 2019 and asking a very basic question.
in that time, i went from almost no knowledge to memorizing most of the functions.
 

halcyonguy

Well-known member
VIP
Lifetime
Hi guys, i am looking for a study that does two things,

1. First, i want to paint a horizontal cloud between a specified price range with a low and high price and i want this cloud to stretch over the entire chart (on the selected timeframe & length) with input options to change the high & low price(s) and also the color of the cloud. And i need at least two of these price ranges in the study so that i can add more ranges later if i want to.

2. Secondly, an alert when price crosses into the cloud but only from below, not from above. Audio and a chartlabel that paints red when inside the cloud, otherwise paints gray.

So here´s an example of how this would look, in the first price range i used a low price of 11.00 and high price 11.05 and in the second range i used low price 11.25 and high price 11.30


I tried asking ChatGPT to write such a study but it wasn´t able to help with this and gave multiple errors. Appreciate if anyone can help with this.

part 1
add a cloud between 2 prices.


first step, look up addcloud()
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AddCloud

look at the data page of the function. it lists out the inputs that can be used.
2 prices
2 colors
yes/no - border

i'll ignore the border parameter, and not use it.


let's make a basic study with 1 command line for testing
Code:
addcloud(12, 11, color.green, color.red);

pick a stock with a price around $11 so the cloud will be seen.
you should see a green cloud across the chart.


now change the price 12 to 10

Code:
addcloud(10, 11, color.green, color.red);

you should see a red cloud.

when the 1st price parameter is higher than the 2nd price, the 1st color is used ( the 3rd parameter)
when the 1st price parameter is lower than the 2nd price, the 2nd color is used ( the 4th parameter)

i try to be consistent and always put the highest price as the 1st parameter and the lower price as the 2nd parameter, then i know the 1st color should be used.
if the prices won't change, then when configuring the addcloud with the highest price as the 1st parameter, the 1st color will always be used, and it isn't needed to provide the 2nd color.
with function and studies, you only need to provide the first few input parameters up to the last desired one.
if a function has 10 inputs , but you only need to supply the 3rd parameter, then you have to provide the first 3 parameters when using the function.


if you want to change the price levels, you can use inputs and go to the edit study settings window and change values,

this will draw 2 green clouds

Code:
input cloud1_top = 11.05;
input cloud1_bot = 11.0;

input cloud2_top = 11.30;
input cloud2_bot = 11.25;

addcloud(cloud1_top, cloud1_bot, color.green, color.red);
addcloud(cloud2_top, cloud2_bot, color.green, color.red);


does this make sense?


q1u4M7e.jpg
 
Last edited:

halcyonguy

Well-known member
VIP
Lifetime
2. Secondly, an alert when price crosses into the cloud but only from below, not from above. Audio and a chartlabel that paints red when inside the cloud, otherwise paints gray.

, in the first price range i used a low price of 11.00 and high price 11.05


there are 2 ways to check if one variable value crosses over another

https://tlc.thinkorswim.com/center/reference/thinkScript/Reserved-Words/crosses
a crosses above b
a crosses below b

https://tlc.thinkorswim.com/center/...nts/CrossingDirection/CrossingDirection-ABOVE
Crosses( a, b , CrossingDirection.ABOVE);
Crosses( a, b , CrossingDirection.below);


@zeek , pick one method and write out some code and add it to my code that draws the 2 clouds.

don't worry about if it actually does anything. lets just build on 1 more piece of the puzzle
 
Last edited:

zeek

Active member
2019 Donor
Appreciate you taking the time to try and learn me this stuff but i am afraid i am a hopeless case when it comes to coding, believe me i have tried:)
Having said that, the addcloud part makes sense and i took the code you provided and also added the border parameter and the clouds show up just as i wanted.

Now for the alerts, i tried with this but something is obvioulsy wrong.

Code:
input cloud1_top = 11.05;
input cloud1_bot = 11.0;

input cloud2_top = 11.30;
input cloud2_bot = 11.25;

addcloud(cloud1_top, cloud1_bot, color.green, color.red, yes);
addcloud(cloud2_top, cloud2_bot, color.green, color.red, yes);

alert(Crosses(close, cloud1_bot, CrossingDirection.ABOVE); Alert.BAR, Sound.Bell);
 

halcyonguy

Well-known member
VIP
Lifetime
Appreciate you taking the time to try and learn me this stuff but i am afraid i am a hopeless case when it comes to coding, believe me i have tried:)
Having said that, the addcloud part makes sense and i took the code you provided and also added the border parameter and the clouds show up just as i wanted.

Now for the alerts, i tried with this but something is obvioulsy wrong.

Code:
input cloud1_top = 11.05;
input cloud1_bot = 11.0;

input cloud2_top = 11.30;
input cloud2_bot = 11.25;

addcloud(cloud1_top, cloud1_bot, color.green, color.red, yes);
addcloud(cloud2_top, cloud2_bot, color.green, color.red, yes);

alert(Crosses(close, cloud1_bot, CrossingDirection.ABOVE); Alert.BAR, Sound.Bell);

you are close,
lets look at alert
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Others/Alert
alert( condition , text , alert type , Sound.ding )

you put a condition in for 1st parameter, but there is a ; after it
you skipped the 2nd parameter , text .
you have a 3rd and 4th parameter.

if i add text and remove ;, then it works
alert(Crosses(close, cloud1_bot, CrossingDirection.ABOVE), "cross into cloud 1" , Alert.BAR, Sound.Bell);


i always set a variable to a condition. then i can use that variable in other formulas and functions

Code:
input cloud1_top = 11.05;
input cloud1_bot = 11.0;

input cloud2_top = 11.30;
input cloud2_bot = 11.25;

addcloud(cloud1_top, cloud1_bot, color.green, color.red, yes);
addcloud(cloud2_top, cloud2_bot, color.green, color.red, yes);

def crossup1 = Crosses(close, cloud1_bot, CrossingDirection.ABOVE);
alert( crossup1, "cross into cloud 1" , Alert.BAR, Sound.Bell);
#
 

Jimmy07

New member
part 1
add a cloud between 2 prices.


first step, look up addcloud()
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AddCloud

look at the data page of the function. it lists out the inputs that can be used.
2 prices
2 colors
yes/no - border

i'll ignore the border parameter, and not use it.


let's make a basic study with 1 command line for testing
Code:
addcloud(12, 11, color.green, color.red);

pick a stock with a price around $11 so the cloud will be seen.
you should see a green cloud across the chart.


now change the price 12 to 10

Code:
addcloud(10, 11, color.green, color.red);

you should see a red cloud.

when the 1st price parameter is higher than the 2nd price, the 1st color is used ( the 3rd parameter)
when the 1st price parameter is lower than the 2nd price, the 2nd color is used ( the 4th parameter)

Trato de ser consistente y siempre pongo el precio más alto como el primer parámetro y el precio más bajo como el segundo parámetro, entonces sé que se debe usar el primer color.
si los precios no cambian, al configurar addcloud con el precio más alto como primer parámetro, siempre se usará el primer color y no es necesario proporcionar el segundo color.
con función y estudios, solo necesita proporcionar los primeros parámetros de entrada hasta el último deseado.
si una función tiene 10 entradas, pero solo necesita proporcionar el tercer parámetro, entonces debe proporcionar los primeros 3 parámetros al usar la función.


si desea cambiar los niveles de precios, puede usar entradas e ir a la ventana de configuración de edición del estudio y cambiar los valores,

esto dibujará 2 nubes verdes

[código]
entrada cloud1_top = 11.05;
entrada cloud1_bot = 11.0;

entrada cloud2_top = 11.30;
entrada cloud2_bot = 11.25;

addcloud(cloud1_top, cloud1_bot, color.verde, color.rojo);
addcloud(cloud2_top, cloud2_bot, color.verde, color.rojo);
[/código]


¿Esto tiene sentido?


q1u4M7e.jpg

part 1
add a cloud between 2 prices.


first step, look up addcloud()
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AddCloud

look at the data page of the function. it lists out the inputs that can be used.
2 prices
2 colors
yes/no - border

i'll ignore the border parameter, and not use it.


let's make a basic study with 1 command line for testing
Code:
addcloud(12, 11, color.green, color.red);

pick a stock with a price around $11 so the cloud will be seen.
you should see a green cloud across the chart.


now change the price 12 to 10

Code:
addcloud(10, 11, color.green, color.red);

you should see a red cloud.

when the 1st price parameter is higher than the 2nd price, the 1st color is used ( the 3rd parameter)
when the 1st price parameter is lower than the 2nd price, the 2nd color is used ( the 4th parameter)

i try to be consistent and always put the highest price as the 1st parameter and the lower price as the 2nd parameter, then i know the 1st color should be used.
if the prices won't change, then when configuring the addcloud with the highest price as the 1st parameter, the 1st color will always be used, and it isn't needed to provide the 2nd color.
with function and studies, you only need to provide the first few input parameters up to the last desired one.
if a function has 10 inputs , but you only need to supply the 3rd parameter, then you have to provide the first 3 parameters when using the function.


if you want to change the price levels, you can use inputs and go to the edit study settings window and change values,

this will draw 2 green clouds

Code:
input cloud1_top = 11.05;
input cloud1_bot = 11.0;

input cloud2_top = 11.30;
input cloud2_bot = 11.25;

addcloud(cloud1_top, cloud1_bot, color.green, color.red);
addcloud(cloud2_top, cloud2_bot, color.green, color.red);


does this make sense?


q1u4M7e.jpg
Could you help me to hide addcloud, I tried but I couldn't. It has some function to make it visible only by changing yes or no
 

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