ATR % Watchlist Column for ThinkorSwim

jngy2k

Member
It is a chart study that shows ATR% label of the past 20 days.

How do I make a column in watchlist ???

Code:
input length = 20;
input averageType = AverageType.Simple;
plot ATR = MovingAverage(averageType, TrueRange(high, close, low), length);
AddLabel (yes, "ATR: " + Round((ATR / close) * 100, 1) + "%", Color.WHITE);
 
You can display the value but not mixed with text, at least not that I am aware of... The code below should work for you...

Ruby:
input length = 20;
input averageType = AverageType.Simple;
plot ATR = Round(MovingAverage(averageType, TrueRange(high, close, low), length) * 100);
ATR.AssignValueColor(Color.BLACK);
AssignBackgroundColor(Color.WHITE);
 

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

@rad14733 Thanks my guy. Looks real good. Works great for people that want to trade momentum stocks. Be well.

UVxnO8P.jpg
 
You can display the value but not mixed with text, at least not that I am aware of... The code below should work for you...

Ruby:
input length = 20;
input averageType = AverageType.Simple;
plot ATR = Round(MovingAverage(averageType, TrueRange(high, close, low), length) * 100);
ATR.AssignValueColor(Color.BLACK);
AssignBackgroundColor(Color.WHITE);
hi sorry i copy and pasted this but for some reason it is not working. see screen shots below. does anyone know what im doing wrong?
1687117635116.png

1687117653018.png
 
Hi Merry Day, am i looking at this wrong then?
ATR/last price
the first row should be around 3.1, not 3257
bottom row should be around 1.5, not 880
Let's back up.

This is the definition for ATR. There is not any other definition. So there is no question if this is "right"
Ruby:
input length = 20;
input averageType = AverageType.Simple;
def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);
This is what is showing up in your watchlist.


Sounds like maybe you are looking for a percentage of ATR in relation to price?
Basic math for a percentage:
(ATR / close) * 100
There is no other way to calculate percentages.

Now put it all together:
Ruby:
# ATR definition
input length = 20;
input averageType = AverageType.Simple;
def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);

# percentage definition
plot pct = Round((ATR / close) * 100, 1) ;

We could do some fancy formatting. But until we agree that math is math. We shouldn't
 
Last edited:
Hi, if I want to display the ATR and the ATR % on my chart, how would I do that. As in a box on the top left of the chart.
 
Last edited by a moderator:
Hi, if I want to display the ATR and the ATR % on my chart, how would I do that. As in a box on the top left of the chart.
ATR and ATR % Label
Ruby:
# ATR and ATR % Label
input length = 20;
input averageType = AverageType.Simple;
def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);

AddLabel(yes,"ATR: " +round(ATR,2) +"  " +asPercent(ATR / close), color.dark_orange);
 
Last edited:
ATR and ATR % Label
Ruby:
# ATR definition
input length = 20;
input averageType = AverageType.Simple;
def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);

AddLabel(yes,"ATR: " +round(ATR,2) +"  " +asPercent(ATR / close), color.dark_orange);
thank you. Is there a way to make the ATR stay static on a D time frame even as I flip through lower time frames. So if I'm on a 30 min chart, it still displays the ATR based on the last X Days (not last x 30 min bars).
 
thank you. Is there a way to make the ATR stay static on a D time frame even as I flip through lower time frames. So if I'm on a 30 min chart, it still displays the ATR based on the last X Days (not last x 30 min bars).
MTF Multi-TimeFrame ATR and ATR % Label
Ruby:
# MTF Multi-TimeFrame ATR and ATR % Label
input length = 20;
input averageType = AverageType.Simple;
input agg = AggregationPeriod.DAY;
def close = close(period = agg);
def high= high(period = agg);
def low= low(period = agg);
def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);

AddLabel(yes,"ATR: " +round(ATR,2) +"  " +asPercent(ATR / close), color.dark_orange);
 
Last edited:
Can you code a TOS watchlist label for me showing the ATR % based on the following script?

-------------------------- Start Code
declare upper;

input AtrAvgLength = 14;

def ATR = WildersAverage(TrueRange(high(period = aggregationPeriod.DAY), close(period = aggregationPeriod.DAY), low(period = aggregationPeriod.DAY)), AtrAvgLength);

def TodayHigh = Highest(high(period = aggregationPeriod.DAY), 1);
def TodayLow = Lowest(low(period = aggregationPeriod.DAY), 1);

def DTR = TodayHigh - TodayLow;

def DTRpct = Round((DTR / ATR) * 100, 0);

AddLabel (yes, "DTR " + Round (DTR , 2) + " vs ATR " + round (ATR,2)+ " " + round (DTRpct,0) + "%", Color.GRAY);

-------------------------- End Code
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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