DTR vs ATR Indicator for ThinkorSwim

Billions

Billions

Active member
2019 Donor
VIP
Does anyone have an ATR Label I can add to the chart
 
S

scottrades

New member
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);
 
S

scottrades

New member
@scottrades I've loaded that study on ROKU, the ATR Daily High is 142.66 and the ATR daily low is 128.68. Hence it does recalculate just fine
Tom, I still cannot figure out how to get this to update throughout the day. Any suggestions?
 
T

tomsk

Well-known member
VIP
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:
S

scottrades

New member
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:
Ace_Trader

Ace_Trader

New member
2019 Donor
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
 
wilmanv

wilmanv

Member
VIP
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
 
inthefutures

inthefutures

Active member
either drag it up or remove the declare lower part of the code, however the scale will be screwie
 
T

tradebyday

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

AddLabel(yes, Concat("ATR=", ATR), Color.YELLOW);
 
traderintheroom

traderintheroom

Member
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 :)
 
mc01439

mc01439

Well-known member
2019 Donor
VIP
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
 
B

bobomatic

New member
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:
S

sreenivasaraovaka

New member
VIP
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.
 
C

chada456

New member
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));
 
lowtrade

lowtrade

Member
VIP
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?
 

Similar threads

Top