DTR vs ATR Indicator for ThinkorSwim

Shinthus

Shinthus

Member
VIP
Ever wonder how much "steam" is left in the day with a particular instrument? If you day trade, this tool helps you decide whether it's worth taking more trades or calling it a day. It shows Daily True Range versus the Average True Range as a % in the upper left corner. I typically don't trade after the DTR reaches 100% but sometimes I'll apply that rule flexibly.

Image for reference:



Indicator: http://tos.mx/Qimvmh
 
Last edited by a moderator:
P

princesly

New member
Warehouse
Great script! Thanks for posting. I have seen stocks that move one direction towards a 100% ATR and still reverse and do the opposite sometimes after 12PM depending on what is going on. So my question is If the percentage recorded is over 100% doesn't that indicate some sort of reversal depending on what is going on with the stock? Since stocks moves in three directions, I am curious which direction you think a DTR that is over a 100% would favor? Or why is is not recommended to trade with a DTR that is above 100%?
 
2

2sureshk

Member
This looks good. but what is the major difference between DTR and ATR calculation.

Is it possible to put ATR = DTR * No times %?
can we add this a column for ATR || DTR on the Watch list?

Thx
Suresh K
 
2

2sureshk

Member
I observed some of the DTR % 160 (NVDA). how to interpret and what is the indication for Long/Entry to buy a stock?
 
markos

markos

Well-known member
VIP
Warehouse
I observed some of the DTR % 160 (NVDA). how to interpret and what is the indication for Long/Entry to buy a stock?
@2sureshk DTR is just Days True Range and ATR is Average True Range. You would need to open the label or study, etc. and look at the code.
Also, Investopedia and School.StockCharts.com are 2 approved places to look for answers outside of tlc.ThinkorSwim.com.
 
S

scottrades

New member
I've found a great label indicator herein showing DTR vs. ATR, but I would like to see a price level, above and below present range, that indicates the level I need in order to reach ATR for the day. Is this possible?
 
T

tomsk

Well-known member
VIP
Warehouse
@scottrades Per your request, here is a label that displays ATR High/Low thresholds relative to the daily open

Code:
# ATR Daily Range
# tomsk
# 12.16.2019

# Displays ATR High/Low thresholds relative to daily open

input length = 14;
input averageType = AverageType.WILDERS;

def o = open(period = AggregationPeriod.DAY);
def h = high(period = AggregationPeriod.DAY);
def l = low(period = AggregationPeriod.DAY);
def c = close(period = AggregationPeriod.DAY);

def ATRD = MovingAverage(averageType, TrueRange(h, c, l), length);

AddLabel(1, "Current Close = " + close, Color.YELLOW);
AddLabel(1, "ATR High/Low Level = [ " + Round(o+ATRD,2) + " / " + Round(o-ATRD,2) + " ]", Color.PINK);
# End ATR Daily Range
MINOR EDITS: Corrected some typos
 
Last edited:
T

tomsk

Well-known member
VIP
Warehouse
@scottrades I corrected some minor typos and updated the version posted
 
T

tomsk

Well-known member
VIP
Warehouse
Folks here is version 1.1 of the ATR Daily High Low Range/Threshold. I thought it might be helpful to determine the percentage performance relative to that range. If you see 100% then you're at the top of the range. A value like 26% tells you we are at the lower 26% of that range

Code:
# ATR Daily Range
# tomsk
# 12.16.2019

# V1.0 - 12.16.2019 - tomsk   - Initial release ATR Daily Range
# V1.1 - 12.16.2019 - tomsk   - Added performance relative to ATR range

# Displays ATR High/Low thresholds relative to daily open

input length = 14;
input averageType = AverageType.WILDERS;

def o = open(period = AggregationPeriod.DAY);
def h = high(period = AggregationPeriod.DAY);
def l = low(period = AggregationPeriod.DAY);
def c = close(period = AggregationPeriod.DAY);
def R = (c - l) / (h - l);
def ATRD = MovingAverage(averageType, TrueRange(h, c, l), length);

AddLabel(1, "ATR Daily High/Low Level = [ " + Round(o+ATRD,2) + " / " + Round(o-ATRD,2) + " ]", Color.PINK);
AddLabel(1, "Current Close = " + close + " [ " + AsPercent(R) + " ]", Color.YELLOW);

# End ATR Daily Range
 
Last edited:
S

scottrades

New member
@scottrades I corrected some minor typos and updated the version posted
Thank you, though I would like see actual price level lines drawn on the chart, not just the label...is that possible?

Edit: Thinking about this...presenting just a bubble for each would be ideal.
 
Last edited:
T

tomsk

Well-known member
VIP
Warehouse
@scottrades Per your request, here is version 1.2 of the code that plots lines for the ATR High/Low levels
Load this study on say a daily chart of AMZN, you'll see it plots nicely, okay?

Code:
# ATR Daily Range
# tomsk
# 12.17.2019

# V1.0 - 12.16.2019 - tomsk   - Initial release ATR Daily Range
# V1.1 - 12.16.2019 - tomsk   - Added performance relative to ATR range
# V1.2 - 12.17.2019 - tomsk   - Added plot lines for ATR High/Low on the chart

# Displays ATR High/Low thresholds relative to daily open

input length = 14;
input averageType = AverageType.WILDERS;

def o = open(period = AggregationPeriod.DAY);
def h = high(period = AggregationPeriod.DAY);
def l = low(period = AggregationPeriod.DAY);
def c = close(period = AggregationPeriod.DAY);
def R = (c - l) / (h - l);
def ATRD = MovingAverage(averageType, TrueRange(h, c, l), length);
def ATRH = o + ATRD;
def ATRL = o - ATRD;

AddLabel(1, "ATR Daily High/Low Level = [ " + Round(ATRH,2) + " / " + Round(ATRL,2) + " ]", Color.PINK);
AddLabel(1, "Current Close = " + close + " [ " + AsPercent(R) + " ]", Color.YELLOW);

def LBN = if isNaN(close[-1]) and !isNaN(close) then barnumber() else Double.NaN;
plot ATR_High = if barNumber() >= highestAll(LBN)
                then highestAll(if isNaN(close[-1]) then ATRH else Double.NaN)
                else Double.NaN;
ATR_High.SetLineWeight(2);
ATR_High.SetDefaultColor(Color.Cyan);

plot ATR_Low = if barNumber() >= highestAll(LBN)
               then highestAll(if isNaN(close[-1]) then ATRL else Double.NaN) else Double.NaN;
ATR_Low.SetLineWeight(2);
ATR_Low.SetDefaultColor(Color.Yellow);
# End ATR Daily Range
 
S

scottrades

New member
@scottrades Per your request, here is version 1.2 of the code that plots lines for the ATR High/Low levels
Load this study on say a daily chart of AMZN, you'll see it plots nicely, okay?
Excellent, thank you!
 
T

tomsk

Well-known member
VIP
Warehouse
@scottrades Come to think of it, this is actually a good tool to use in my option expiration trades
I appreciate the suggestion!
 
S

scottrades

New member
@scottrades Per your request, here is version 1.2 of the code that plots lines for the ATR High/Low levels
Load this study on say a daily chart of AMZN, you'll see it plots nicely, okay?
Script not re-calculating. For example, see $ROKU chart image below. Based on the HOD, the low end of the ATR should reflect 131.78. However, it's still showing 128.68, which was correct at open.

 
Last edited:
T

tomsk

Well-known member
VIP
Warehouse
@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
 
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
I would like the study to adjust throughout the trading day, not simply provide markers at open. Using the chart example above, ROKU rose to 138.77 around 10:00; the downside ATR would then need to be adjusted to 131.78, to keep the ATR.
 

Top