Here's what I use... There is a label option if you wish to change the colorDoes anyone have an ATR Label I can add to the chart
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?@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?
def o = open;
def h = high;
def l = low;
def c = close;
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.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.
# ------ 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
input ATRLength = 14;
def ATR = Round(Average(TrueRange(high, close, low), ATRLength), 2);
AddLabel(yes, Concat("ATR=", ATR), Color.YELLOW);
Try this. You can change the length and turn off want you do not want through the input.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
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);
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?
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Start a new thread and receive assistance from our community.
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.
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.