Simple Script To Create A Manual Cloud

Status
Not open for further replies.

stockdaddy

New member
Hello,
I don't know why this is so hard to find, I have searched many threads.
My code is simple, create and AddCloud() function that starts on a specific date & time with a high and low range.
I can get everything I need except for the cloud to start at a specific time.
Seems simple but just can't figure out the easiest way to achieve it?
Any help would be greatly appreciated.

Code:
# Manual display of a single supply or demand cloud
#

input showCloud = yes;

input Startdate = 20221215;
input Starttime = 1030;
input Enddate = 20221231;
input recLow = 4000;
input recHigh = 4100;
input isSupply = {default "Yes", "No"};

def sDate = (GetYYYYMMDD() >= Startdate);
def sTime = (Gettime() >= Starttime);
def rLow = recLow;
def rHigh = recHigh;


AddCloud(if (showcloud and sdate and sTime and isSupply) then rHigh else Double.NaN, rLow, color.GREEN);

AddCloud(if (showcloud and sdate and sTime and isSupply is false) then rHigh else Double.NaN, rLow, color.RED);

Hopefully more adequate programmers than myself will be able to help me :)
 
Solution
1. Supply & Demand data (buying and selling volume) is not available on the ToS platform.​
There is no coding related to supply and demand in this thread. There is no volume imbalance code,​
This is a simple script to create a manual cloud.​

2. The cloud is drawn based on information collected from across the web:​
Numerous factors that go into identifying "proper" supply/demand zones. I have read most of the books on it and have been practicing drawing the zones for many months now.​

For more information: there are many great books on how to do your own Supply / Demand Zone Analysis.
Hello,
I don't know why this is so hard to find, I have searched many threads.
My code is simple, create and AddCloud() function that starts on a specific date & time with a high and low range.
I can get everything I need except for the cloud to start at a specific time.
Seems simple but just can't figure out the easiest way to achieve it?
Any help would be greatly appreciated.

Code:
# Manual display of a single supply or demand cloud
#

input showCloud = yes;

input Startdate = 20221215;
input Starttime = 1030;
input Enddate = 20221231;
input recLow = 4000;
input recHigh = 4100;
input isSupply = {default "Yes", "No"};

def sDate = (GetYYYYMMDD() >= Startdate);
def sTime = (Gettime() >= Starttime);
def rLow = recLow;
def rHigh = recHigh;


AddCloud(if (showcloud and sdate and sTime and isSupply) then rHigh else Double.NaN, rLow, color.GREEN);

AddCloud(if (showcloud and sdate and sTime and isSupply is false) then rHigh else Double.NaN, rLow, color.RED);

sDate was redefined using the between function which included Endate
sTime was redefined using secondsfromtime() function as gettime() cannot be used with the input Starttime
rlow and rhigh were defined starting at sDate and sTime and were extended by the recursives rlow[1] and rhigh[1]
As TOS does not allow recursives in the addcloud function rLow1 and rHigh1 were defined as plots which were hidden

The image shows isSupply set to No and the chart is expanded to 2023 to show Enddate of 20221231 used
Screenshot-2022-12-26-164347.png
# Manual display of a single supply or demand cloud
#

input showCloud = yes;

input Startdate = 20221215;
input Starttime = 1030;
input Enddate = 20221231;
input recLow = 4000;
input recHigh = 4100;
input isSupply = yes;

def sDate = if Between(GetYYYYMMDD(), Startdate, Enddate) then 1 else Double.NaN;
def sTime = SecondsFromTime(Starttime) == 0;
def rLow = if sDate and sTime then recLow else rLow[1];
def rHigh = if sDate and sTime then recHigh else rHigh[1];
plot rhigh1 = rHigh;
plot rLow1 = rLow;
rhigh1.SetHiding(yes);
rLow1.SetHiding(yes);

AddCloud(if showCloud and isSupply then rhigh1 else Double.NaN, rLow1, Color.GREEN, Color.GREEN);
AddCloud(if showCloud and !isSupply then rhigh1 else Double.NaN, rLow1, Color.RED, Color.RED);

#
 

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

sDate was redefined using the between function which included Endate
sTime was redefined using secondsfromtime() function as gettime() cannot be used with the input Starttime
rlow and rhigh were defined starting at sDate and sTime and were extended by the recursives rlow[1] and rhigh[1]
As TOS does not allow recursives in the addcloud function rLow1 and rHigh1 were defined as plots which were hidden

The image shows isSupply set to No and the chart is expanded to 2023 to show Enddate of 20221231 used
I can't thank you enough! You've taught an old dog a new trick :)
 
I can't thank you enough! You've taught an old dog a new trick :)
What are you using this to see exactly? The high and low of a specified range within a specified timeframe? More so like support and resistance?

Oh ok, yea I know it's a difference but many people seem to think they're the same for some weird strange reason, I too take the time to draw them but it's time consuming going through the time-frames to find them if you're reading multiple tickers. I was trying to understand the code from reading it but was a little lost behind the logic which determines if in fact the box drawn is a S&D zone... Is it based off of past brutal rejections on larger time-frames?

So with your indicator here, when the boxes are drawn what determines it? Is it being drawn based off of an imbalance? Wondering about the logic behind this indicator since I didn't see it in the code. What is the indicator based off of to create the S&D zones?
 
Last edited by a moderator:
What are you using this to see exactly? The high and low of a specified range within a specified timeframe? More so like support and resistance?
I'm using it to draw supply and demand zones, which are different than support/resistance lines. I could just use the "rectangle" tool to draw them but eventually I want to expand the code to allow input of say five different supply zones and five different demand zones. At that point it will be easier to use the "inputs" from a study as opposed to manually drawing each zone.

There are numerous factors that go into identifying "proper" supply/demand zones. I have read most of the books on it and have been practicing drawing the zones for many months now. I only trade /ES futures based on the daily, 1-Hr and 30 min charts which helps me focus my time. You're correct that if you are trying to identify zones for more than five stocks then you have to really spend some time.

I hope that answers your question.
 
Last edited by a moderator:
1. Supply & Demand data (buying and selling volume) is not available on the ToS platform.​
There is no coding related to supply and demand in this thread. There is no volume imbalance code,​
This is a simple script to create a manual cloud.​

2. The cloud is drawn based on information collected from across the web:​
Numerous factors that go into identifying "proper" supply/demand zones. I have read most of the books on it and have been practicing drawing the zones for many months now.​

For more information: there are many great books on how to do your own Supply / Demand Zone Analysis.
 
Last edited:
Solution
Status
Not open for further replies.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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