DTR vs ATR Indicator for ThinkorSwim

Does anyone have an ATR Label I can add to the chart
Here's what I use... There is a label option if you wish to change the color
Code:
input length2 = 14;
input ATRaverageType = AverageType.WILDERS;

def dailyHigh = high(period = “DAY”);
def dailyLow = low(period = “DAY”);
def dailyClose = close(period = “DAY”);

plot ATR = Round(MovingAverage(ATRaverageType, TrueRange(dailyHigh, dailyClose, dailyLow), length2));
#AddLabel(yes, “DATR: “+ATR, if ATR > 1.00 then Color.GREEN else if ATR > .50 then Color.YELLOW else Color.WHITE);
AddLabel(yes, Concat(“DATR= ”, ATR), Color.YELLOW);
 
Tom, I still cannot figure out how to get this to update throughout the day. Any suggestions?


My earlier posts on this thread (see post #9, #12, and #15) specifically specified in the header of the study that it was an ATR relative to the daily open. From your description sounds like all you need is to replace the secondary aggregation in the original code as follows. However in so doing you are changing the character of the study, and it won't be based on the daily open. Just be aware of that

Code:
def o = open;
def h = high;
def l = low;
def c = close;
 
Last edited:
My earlier posts on this thread (see post #9, #12, and #15) specifically specified in the header of the study that it was an ATR relative to the daily open.
I got that to mean it would calculate off the open, which is what I want. I'll make the change and see what it gives me. thank you.

Edit: Your script is exactly what I was looking for, except, I would like it to automatically adjust throughout the trading day. Right now, it calculates the levels at open, but does not adjust, taking into account any movement up/down.
 
Last edited:
Here is another variation of this indicator you guys can try.....
Code:
# ------ START CODE

input ATRPeriod = 20; #Hint ATRPeriod: The ATR period for previous days, default 14.

def period = AggregationPeriod.DAY;
def ATR = MovingAverage(AverageType.WILDERS, TrueRange(high(period = period), close(period = period), low(period = period)), ATRperiod);
def showATralways = yes;

def dayrng = Round((high(period = AggregationPeriod.DAY) - low(period = AggregationPeriod.DAY)),2);
AddLabel(showATRalways, "DayRng: " + dayrng + " vs. ATR: " + Round(ATR,2) + " (" + Round(((dayrng/ATR)*100),2) +"%)" , color.green);

# ------- END CODE
 
Any script to know how much the ATR (%) was moved during the open market: sample : The market open 9:30 I need to know on 10:30 what % the ATR has moved ?

Thanks
 
This should work
Code:
input ATRLength = 14;
def ATR = Round(Average(TrueRange(high,  close,  low),  ATRLength), 2);

AddLabel(yes, Concat("ATR=", ATR), Color.YELLOW);
 
I am sure this is a simple one, but I am struggling today. Working on cleaning up my charts.

I use the out of the box on Thinkorswim ATR study (ATR: 5, Wilders drawn as lines on lower axis) to determine the range of the last 5 candles on my 5 min. chart. Can someone help / share a code to have this shown as a label only (not as study shown). Thank you :)
 
I am sure this is a simple one, but I am struggling today. Working on cleaning up my charts.

I use the out of the box on Thinkorswim ATR study (ATR: 5, Wilders drawn as lines on lower axis) to determine the range of the last 5 candles on my 5 min. chart. Can someone help / share a code to have this shown as a label only (not as study shown). Thank you :)
Try this. You can change the length and turn off want you do not want through the input.

https://tos.mx/BG2LsAb
 
Here's something very similar I found but presented differently. ATR label. When ATR is below 1.4/5 I sit on my hands Timeframe based perfect for scalpers, adjust as needed. Been testing for a few weeks. I like it for choppy areas to keep me out.

Code:
Declare upper;
input length = 14;
plot currentATR = reference ATR(length, averageType = AverageType.wilders);
currentATR.Hide();
def up= 2.6;
def dn = 1.5;

def atrlow = currentatr > dn;
def atrhigh = currentatr > up;

AddLabel(yes, Concat(currentatr , Concat(" ",
if atrhigh then "8 ticks" else if atrlow then "4 ticks" else "NO TRADES")),
if atrhigh then Color.GREEN else
if atrlow then Color.LIGHT_gray else Color.WHITE);
 
Last edited by a moderator:
Hello Ben,
Can you please help on below Label.
I am using below calculation for ATR on a chart. ATR label is working fine. Can you please help me how can I get average ATR based on multiple daily times?

input ATRLength = 14;
def ATR = Round(Average(TrueRange(high, close, low), ATRLength), 2)
AddLabel(yes, Concat("ATR=", ATR), Color.YELLOW);

Ex: 5 min ATR: 1.51, 10 min ATR is 2.1, 15 mins ATR: 2.49, 30 mins ATR: 6.18, 1hr ATR : 6.36;
Now I want average ATR which is 3.7.

Thank you.
 
I got a great study from this awesome forum but I'd like to use it to scan for stocks based on the study's percentage. Can someone please help? It's a DTR vs ATR study. The study itself shows the % but I don't know how to scan based on that %. I'd like to find stocks that that have a DTR 100%+ greater than its ATR. Thanks!

Here is the study's script:

# Custom ATR Plot by 7of9 for BRT
# edited 3/20/19

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) + "%", (if DTRpct <= 70 then Color.GREEN else if DTRpct >= 90 then Color.RED else Color.ORANGE));
 
I was looking at the original thread for this script and they said, they were having some issue with values. Did you figure it out?
 
I was looking at the original thread for this script and they said, they were having some issue with values. Did you figure it out?

It looks great to me. An example of this is SFIX from yesterday. It shows a DTR of $5.26.. That's accurate as the low from that day was 18.84 and the high was 24.10 (24.10 - 18.84 = 5.26) The percentage it outputs (which is what i would love to get in a scan) is 319% above it's ATR which is also accurate. Hope that helps.
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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