@hydroflask Do another as in write another line of code that checks the ATR in a decreasing order. Hope that helps.
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
#Study:Info
#by thetrader.top
input ATRLength = 14;
input ShowATR = {default “1”, “0”}; #Average True Range
input AvgVolume = {default “1”, “0”}; #Average volume for the last 14 days
input Volume_ = {default “1”, “0”}; #Volume for today
input ATRPlay = {default “1”, “0”}; #How many ATR’s stock moved today
input VolumePlay = {default “1”, “0”}; #How many of its average volumes stock traded for the last 65 days.
def _ATR_D = TrueRange(high(period = “DAY”), close(period = “DAY”), low(period = “DAY”));
def iATR_D = Round(Average(_ATR_D, ATRLength)[1], 2);
AddLabel (!ShowATR, “ATR(“ + ATRLength + ”) “ + iATR_D, Color.GRAY);
def iAvgVolume = Round(Average (volume(period = “DAY”)[1], 65) / 1000, 0);
AddLabel (!AvgVolume, “AvgVol “ + iAvgVolume + “k”, Color.GRAY);
def iVolume = Round(volume(period = “DAY”) / 1000, 0);
AddLabel (!Volume_, “Vol “ + iVolume + “k”, Color.LIGHT_GREEN);
#def iATRPlay = Round((high(period = “DAY”) — low(period = “DAY”)) / iATR_D, 1);
#AddLabel (!ATRPlay, “ATRPlay “ + iATRPlay + “(“ + Round(high(period = “DAY”) — low(period = “DAY”), 2) + “)”, Color.LIGHT_GREEN);
def iVolumePlay = Round(iVolume / iAvgVolume, 2);
AddLabel (!VolumePlay, “VolPlay “ + iVolumePlay, Color.LIGHT_GREEN);
def Gap = Round((open(period = “DAY”) - close(period = “DAY”)[1]) / close(period = “DAY”)[1] * 100, 2);
AddLabel (yes, “Gap “ + Gap + ”%”, Color.LIGHT_GREEN);
def ATRcur = Round (Average(TrueRange(high, close, low)[1], 5));
AddLabel (yes, “ATR(5) “ + ATRcur, if (ATRcur <= 0.20) then Color.GREEN else Color.RED);
#Study:Info
#by thetrader.top
input ATRLength = 14;
input ShowATR = {default “1”, “0”}; #Average True Range
input AvgVolume = {default “1”, “0”}; #Average volume for the last 14 days
input Volume_ = {default “1”, “0”}; #Volume for today
input ATRPlay = {default “1”, “0”}; #How many ATR’s stock moved today
input VolumePlay = {default “1”, “0”}; #How many of its average volumes stock traded for the last 65 days.
def _ATR_D = TrueRange(high(period = “DAY”), close(period = “DAY”), low(period = “DAY”));
def iATR_D = Round(Average(_ATR_D, ATRLength)[1], 2);
AddLabel (!ShowATR, “ATR(“ + ATRLength + ”) “ + iATR_D, Color.GRAY);
def iAvgVolume = Round(Average (volume(period = “DAY”)[1], 65) / 1000, 0);
AddLabel (!AvgVolume, “AvgVol “ + iAvgVolume + “k”, Color.GRAY);
def iVolume = Round(volume(period = “DAY”) / 1000, 0);
AddLabel (!Volume_, “Vol “ + iVolume + “k”, Color.LIGHT_GREEN);
def iATRPlay = Round((high(period = “DAY”) - low(period = “DAY”) / iATR_D), 1);
AddLabel (!ATRPlay, “ATRPlay “ + iATRPlay + “(“ + Round(high(period = “DAY”) - low(period = “DAY”), 2) + “)”, Color.LIGHT_GREEN);
def iVolumePlay = Round(iVolume / iAvgVolume, 2);
AddLabel (!VolumePlay, “VolPlay “ + iVolumePlay, Color.LIGHT_GREEN);
def Gap = Round((open(period = “DAY”) - close(period = “DAY”)[1]) / close(period = “DAY”)[1] * 100, 2);
AddLabel (yes, “Gap “ + Gap + ”%”, Color.LIGHT_GREEN);
def ATRcur = Round (Average(TrueRange(high, close, low)[1], 5));
AddLabel (yes, “ATR(5) “ + ATRcur, if (ATRcur <= 0.20) then Color.GREEN else Color.RED);
Thank you! You da man!Code:#Study:Info #by thetrader.top input ATRLength = 14; input ShowATR = {default “1”, “0”}; #Average True Range input AvgVolume = {default “1”, “0”}; #Average volume for the last 14 days input Volume_ = {default “1”, “0”}; #Volume for today input ATRPlay = {default “1”, “0”}; #How many ATR’s stock moved today input VolumePlay = {default “1”, “0”}; #How many of its average volumes stock traded for the last 65 days. def _ATR_D = TrueRange(high(period = “DAY”), close(period = “DAY”), low(period = “DAY”)); def iATR_D = Round(Average(_ATR_D, ATRLength)[1], 2); AddLabel (!ShowATR, “ATR(“ + ATRLength + ”) “ + iATR_D, Color.GRAY); def iAvgVolume = Round(Average (volume(period = “DAY”)[1], 65) / 1000, 0); AddLabel (!AvgVolume, “AvgVol “ + iAvgVolume + “k”, Color.GRAY); def iVolume = Round(volume(period = “DAY”) / 1000, 0); AddLabel (!Volume_, “Vol “ + iVolume + “k”, Color.LIGHT_GREEN); def iATRPlay = Round((high(period = “DAY”) - low(period = “DAY”) / iATR_D), 1); AddLabel (!ATRPlay, “ATRPlay “ + iATRPlay + “(“ + Round(high(period = “DAY”) - low(period = “DAY”), 2) + “)”, Color.LIGHT_GREEN); def iVolumePlay = Round(iVolume / iAvgVolume, 2); AddLabel (!VolumePlay, “VolPlay “ + iVolumePlay, Color.LIGHT_GREEN); def Gap = Round((open(period = “DAY”) - close(period = “DAY”)[1]) / close(period = “DAY”)[1] * 100, 2); AddLabel (yes, “Gap “ + Gap + ”%”, Color.LIGHT_GREEN); def ATRcur = Round (Average(TrueRange(high, close, low)[1], 5)); AddLabel (yes, “ATR(5) “ + ATRcur, if (ATRcur <= 0.20) then Color.GREEN else Color.RED);
I got the errors but corrected in above code. Seemed problem was here. Shown in bold.
def iATRPlay = Round((high(period = “DAY”) — low(period = “DAY”)) / iATR_D, 1);
AddLabel (!ATRPlay, “ATRPlay “ + iATRPlay + “(“ + Round(high(period = “DAY”) — low(period = “DAY”), 2) + “)”, Color.LIGHT_GREEN);
# Custom ATR Plot by 7of9 for BRT
# edited 3/20/19
# Modified by BenTen to plot DTR as a watchlist column
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);
plot Data = DTRpct;
# ATRLabel
#
# Displays Average True Range over the last 40 periods and the current period
#
input ATRLength = 40;
# historical ATR
def ATRValue = Average(TrueRange(high, close, low), ATRLength);
def ATRPercent = ATRValue / close * 100;
# current period range
def ATRLastBar = TrueRange(high, close, low);
AddLabel(yes, ATRLength + " Period ATR = $" + Round(ATRValue, 2) + " (" + Round(ATRPercent, 2) + "%), Current Period Range = $" + Round(ATRLastBar, 2) + " (" + Round(ATRLastBar / close * 100, 2) + "%)", CreateColor(153, 153, 0));
if ATRLastBar <= .25 * ATRValue then color.orange else if ATRLastBar <= .5 * ATRValue then color.red else color.green
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.