# How to create a time cloud from a user's starting point's choice that goes on for 3 periods of 30 minutes each.

#### Guille

##### New member
I would like to create a cloud on my charts that runs for 3 sections of 30 minutes each and is of different color at each segment to make me stay longer on my trades and change to different phases within my trades. Can anybody help?

Solution
I would like to create a cloud on my charts that runs for 3 sections of 30 minutes each and is of different color at each segment to make me stay longer on my trades and change to different phases within my trades. Can anybody help?

Input the time to begin and the minutes (defaulted to 30). You can change the cloud colors to your liking at the input screen.

Ruby:
``````input begin   = 1003;
input minutes = 30;

def bar       = if getday()==getlastday()
then if SecondsfromTime(begin)[1]< 0 and
SecondsFromTime(begin) >= 0
then 0
else bar[1] + 1
else...``````
I would like to create a cloud on my charts that runs for 3 sections of 30 minutes each and is of different color at each segment to make me stay longer on my trades and change to different phases within my trades. Can anybody help?

Input the time to begin and the minutes (defaulted to 30). You can change the cloud colors to your liking at the input screen.

Ruby:
``````input begin   = 1003;
input minutes = 30;

def bar       = if getday()==getlastday()
then if SecondsfromTime(begin)[1]< 0 and
SecondsFromTime(begin) >= 0
then 0
else bar[1] + 1
else double.nan;
def barx_min  = bar % ((minutes) / (GetAggregationPeriod() / 60000)) == 0;
def barxct    = if isnan( barx_min[1]) and barx_min==1
then 1
else if barxct[1]>=1 and barx_min==1
then barxct[1]+1
else barxct[1] ;

def h = Double.POSITIVE_INFINITY;
def l = Double.NEGATIVE_INFINITY;
defineglobalColor("C1", color.white);
defineglobalColor("C2", color.cyan);
defineglobalColor("C3", color.magenta);
def ORH1 = if barxct==1
then h else Double.NaN;
def ORL1 = if barxct==1
then l
else Double.NaN;
AddCloud(ORH1, ORL1, globalColor("C1"), globalColor("C1"));
def ORH2 = if barxct==2
then h else Double.NaN;
def ORL2 = if barxct==2
then l
else Double.NaN;
AddCloud(ORH2, ORL2, globalColor("C2"), globalColor("C2"));
def ORH3 = if barxct==3
then h else Double.NaN;
def ORL3 = if barxct==3
then l
else Double.NaN;
AddCloud(ORH3, ORL3, globalColor("C3"), globalColor("C3"));``````

Input the time to begin and the minutes (defaulted to 30). You can change the cloud colors to your liking at the input screen.
SleepyZ, the clouds work like a charm but I realized that all of my charts would show the cloud at the same time even when showing different tickers. So, it's really not practical. I really appreciate your help, though. Thank you very much!

SleepyZ, the clouds work like a charm but I realized that all of my charts would show the cloud at the same time even when showing different tickers. So, it's really not practical. I really appreciate your help, though. Thank you very much!

So if you have a symbols you always use, instead of one input for the begin time, you can create a list with various begin times unique to each one. Then when you switch symbols on your chart to one of them, then it will use the begin time for that chart's symbol.

Here is the pertinent code in the following full code
Ruby:
``````]def begin =

if getsymbol() == "AAPL"

then 1003

else if getsymbol() == "TSLA"

then 903

else if getsymbol() == "FB"

then 953

else 1000;``````

Full Code
Ruby:
``````def begin =
if getsymbol() == "AAPL"
then 1003
else if getsymbol() == "TSLA"
then 903
else if getsymbol() == "FB"
then 953
else 1000;

input minutes = 30;

def bar       = if GetDay() == GetLastDay()
then if SecondsFromTime(begin)[1] < 0 and
SecondsFromTime(begin) >= 0
then 0
else bar[1] + 1
else Double.NaN;
def barx_min  = bar % ((minutes) / (GetAggregationPeriod() / 60000)) == 0;
def barxct    = if IsNaN( barx_min[1]) and barx_min == 1
then 1
else if barxct[1] >= 1 and barx_min == 1
then barxct[1] + 1
else barxct[1] ;

def h = Double.POSITIVE_INFINITY;
def l = Double.NEGATIVE_INFINITY;
DefineGlobalColor("C1", Color.WHITE);
DefineGlobalColor("C2", Color.CYAN);
DefineGlobalColor("C3", Color.MAGENTA);
def ORH1 = if barxct == 1
then h else Double.NaN;
def ORL1 = if barxct == 1
then l
else Double.NaN;
AddCloud(ORH1, ORL1, GlobalColor("C1"), GlobalColor("C1"));
def ORH2 = if barxct == 2
then h else Double.NaN;
def ORL2 = if barxct == 2
then l
else Double.NaN;
AddCloud(ORH2, ORL2, GlobalColor("C2"), GlobalColor("C2"));
def ORH3 = if barxct == 3
then h else Double.NaN;
def ORL3 = if barxct == 3
then l
else Double.NaN;
AddCloud(ORH3, ORL3, GlobalColor("C3"), GlobalColor("C3"));``````

### Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
287 Online

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