Plot cloud across weeks/months instead of just day

roughsleeper

New member
Hey all,

I made a quick study that shows a range I'm looking at for each day, and it's working out nicely per day, but I'd like to plot these clouds/lines in a different way.

I'm trying to plot only yesterday's levels across the entire chart (including today) – back weeks or months – and hide every other level previous to yesterday's levels.

Here's a visual of where I'm at:

Screen-Shot-2021-12-01-at-9-37-50-AM.png


and here's what I'm trying to make happen (with lines / clouds etc. same as above) – take yesterday's levels and apply them all the way back. I can't figure out how to do it.

Screen-Shot-2021-12-01-at-9-43-16-AM.png



And the code:

Code:
input length = 10;
input averageType = AverageType.WILDERS;

def ATR20 = MovingAverage(averageType, TrueRange(high(period=”DAY”)[1], close(period=”DAY”)[1], low(period=”DAY”)[1]), length)/5;
def ATR25 = MovingAverage(averageType, TrueRange(high(period=”DAY”)[1], close(period=”DAY”)[1], low(period=”DAY”)[1]), length)/4;

plot dailyClose = close(period=”DAY”)[1];

plot high20 = dailyClose + ATR20;
plot high25 = dailyClose + ATR25;
AddCloud(high20, high25, color.LIGHT_GRAY, color.LIGHT_GRAY);


plot low20 = dailyClose - ATR20;
plot low25 = dailyClose - ATR25;
AddCloud(low20, low25, color.LIGHT_GRAY, color.LIGHT_GRAY);

dailyClose.SetDefaultColor(color.LIME);
high20.SetDefaultColor(color.LIGHT_GRAY);
low20.SetDefaultColor(color.LIGHT_GRAY);
high25.SetDefaultColor(color.LIGHT_GRAY);
low25.SetDefaultColor(color.LIGHT_GRAY);


any help is appreciated! thanks!
 
Solution
Hey all,

I made a quick study that shows a range I'm looking at for each day, and it's working out nicely per day, but I'd like to plot these clouds/lines in a different way.

I'm trying to plot only yesterday's levels across the entire chart (including today) – back weeks or months – and hide every other level previous to yesterday's levels.

Here's a visual of where I'm at:

Screen-Shot-2021-12-01-at-9-37-50-AM.png


and here's what I'm trying to make happen (with lines / clouds etc. same as above) – take yesterday's levels and apply them all the way back. I can't figure out how to do it.

Screen-Shot-2021-12-01-at-9-43-16-AM.png



And the code:

Code:
input length = 10;
input averageType = AverageType.WILDERS;

def ATR20 = MovingAverage(averageType, TrueRange(high(period=”DAY”)[1]...
Hey all,

I made a quick study that shows a range I'm looking at for each day, and it's working out nicely per day, but I'd like to plot these clouds/lines in a different way.

I'm trying to plot only yesterday's levels across the entire chart (including today) – back weeks or months – and hide every other level previous to yesterday's levels.

Here's a visual of where I'm at:

Screen-Shot-2021-12-01-at-9-37-50-AM.png


and here's what I'm trying to make happen (with lines / clouds etc. same as above) – take yesterday's levels and apply them all the way back. I can't figure out how to do it.

Screen-Shot-2021-12-01-at-9-43-16-AM.png



And the code:

Code:
input length = 10;
input averageType = AverageType.WILDERS;

def ATR20 = MovingAverage(averageType, TrueRange(high(period=”DAY”)[1], close(period=”DAY”)[1], low(period=”DAY”)[1]), length)/5;
def ATR25 = MovingAverage(averageType, TrueRange(high(period=”DAY”)[1], close(period=”DAY”)[1], low(period=”DAY”)[1]), length)/4;

plot dailyClose = close(period=”DAY”)[1];

plot high20 = dailyClose + ATR20;
plot high25 = dailyClose + ATR25;
AddCloud(high20, high25, color.LIGHT_GRAY, color.LIGHT_GRAY);


plot low20 = dailyClose - ATR20;
plot low25 = dailyClose - ATR25;
AddCloud(low20, low25, color.LIGHT_GRAY, color.LIGHT_GRAY);

dailyClose.SetDefaultColor(color.LIME);
high20.SetDefaultColor(color.LIGHT_GRAY);
low20.SetDefaultColor(color.LIGHT_GRAY);
high25.SetDefaultColor(color.LIGHT_GRAY);
low25.SetDefaultColor(color.LIGHT_GRAY);


any help is appreciated! thanks!
here is one way

Ruby:
def na = double.nan;
def bn = barnumber();
# -----------------------------
# define yesterday
def Yesterday = if GetDay() == (GetLastDay() - 1) then 1 else 0;
input include_after_hour_data = no;
def rth = if secondsFromTime(0930) >= 0 and secondsTillTime(1600) > 0 then 1 else 0;
def getdata = if include_after_hour_data then 1 else rth;
def prevday = (yesterday == 1 and getdata == 1);
# -------------------------------
input length = 10;
input averageType = AverageType.WILDERS;
def ATR20 = MovingAverage(averageType, TrueRange(high(period=”DAY”)[1], close(period=”DAY”)[1], low(period=”DAY”)[1]), length)/5;
def ATR25 = MovingAverage(averageType, TrueRange(high(period=”DAY”)[1], close(period=”DAY”)[1], low(period=”DAY”)[1]), length)/4;
def dailyClose = if prevday then close(period = "DAY")[1] else na;
def high20 =  if prevday then (dailyClose + ATR20) else na;
def high25 =  if prevday then (dailyClose + ATR25) else na;
def low20 =  if prevday then (dailyClose - ATR20) else na;
def low25 =  if prevday then (dailyClose - ATR25) else na;

plot dcls = highestall(dailyclose);
plot h20 = highestall(high20);
plot h25 = highestall(high25);
plot l20 = highestall(low20);
plot l25 = highestall(low25);

dcls.SetDefaultColor(color.LIME);
h20.SetDefaultColor(color.LIGHT_GRAY);
l20.SetDefaultColor(color.LIGHT_GRAY);
h25.SetDefaultColor(color.LIGHT_GRAY);
l25.SetDefaultColor(color.LIGHT_GRAY);

AddCloud(h20, h25, color.LIGHT_GRAY, color.LIGHT_GRAY);
AddCloud(l20, l25, color.LIGHT_GRAY, color.LIGHT_GRAY);

#-------------------------------
input show_line_above_day = no;
plot w = if (show_line_above_day  and prevday) then ( 1.000 * high(period = "DAY")[1] ) else na;
w.SetDefaultColor(Color.light_gray);

# ---------------------------
input test_show_day_dots = no;
plot z = if (test_show_day_dots and prevday) then (low*0.99) else na;
z.SetPaintingStrategy(PaintingStrategy.points);
z.SetDefaultColor(Color.cyan);
z.setlineweight(3);
#

borrowed from this code
https://usethinkscript.com/threads/...-in-thinkorswim-scanner.927/page-2#post-79181
 
Solution

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

here is one way

Ruby:
def na = double.nan;
def bn = barnumber();
# -----------------------------
# define yesterday
def Yesterday = if GetDay() == (GetLastDay() - 1) then 1 else 0;
input include_after_hour_data = no;
def rth = if secondsFromTime(0930) >= 0 and secondsTillTime(1600) > 0 then 1 else 0;
def getdata = if include_after_hour_data then 1 else rth;
def prevday = (yesterday == 1 and getdata == 1);
# -------------------------------
input length = 10;
input averageType = AverageType.WILDERS;
def ATR20 = MovingAverage(averageType, TrueRange(high(period=”DAY”)[1], close(period=”DAY”)[1], low(period=”DAY”)[1]), length)/5;
def ATR25 = MovingAverage(averageType, TrueRange(high(period=”DAY”)[1], close(period=”DAY”)[1], low(period=”DAY”)[1]), length)/4;
def dailyClose = if prevday then close(period = "DAY")[1] else na;
def high20 =  if prevday then (dailyClose + ATR20) else na;
def high25 =  if prevday then (dailyClose + ATR25) else na;
def low20 =  if prevday then (dailyClose - ATR20) else na;
def low25 =  if prevday then (dailyClose - ATR25) else na;

plot dcls = highestall(dailyclose);
plot h20 = highestall(high20);
plot h25 = highestall(high25);
plot l20 = highestall(low20);
plot l25 = highestall(low25);

dcls.SetDefaultColor(color.LIME);
h20.SetDefaultColor(color.LIGHT_GRAY);
l20.SetDefaultColor(color.LIGHT_GRAY);
h25.SetDefaultColor(color.LIGHT_GRAY);
l25.SetDefaultColor(color.LIGHT_GRAY);

AddCloud(h20, h25, color.LIGHT_GRAY, color.LIGHT_GRAY);
AddCloud(l20, l25, color.LIGHT_GRAY, color.LIGHT_GRAY);

#-------------------------------
input show_line_above_day = no;
plot w = if (show_line_above_day  and prevday) then ( 1.000 * high(period = "DAY")[1] ) else na;
w.SetDefaultColor(Color.light_gray);

# ---------------------------
input test_show_day_dots = no;
plot z = if (test_show_day_dots and prevday) then (low*0.99) else na;
z.SetPaintingStrategy(PaintingStrategy.points);
z.SetDefaultColor(Color.cyan);
z.setlineweight(3);
#

borrowed from this code
https://usethinkscript.com/threads/...-in-thinkorswim-scanner.927/page-2#post-79181

Oh whoa thank you so much halcyonguy! I really appreciate that. This is looking so good.

I might've misspoke in my post, I'm looking to have the current day's range plotted for the next trading day. So basically the idea is, take today's close, figure out 20/25% ATR from (x) days back, and create bands on tomorrow's day period that are 20-25% ATR above and below current day's close.

Here are both overlaid – I'm trying to get the levels from the pink arrow area plotted across (+ also check the areas that are currently being plotted for tomorrow):

Screen-Shot-2021-12-02-at-7-56-17-AM.png


thanks again


**Err I think I may have figured it out by changing all of your [1]'s to [0]'s – does that seem right?
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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