DTR vs ATR Indicator for ThinkorSwim

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

Hi, can some get the only atr vs dtr %value on watchlist that can be seen on mobile tos? I've tried a few here but it didn't show up on tos mobile watchlist column. Thank you!
 
@Ninja Bull Here you go:

Code:
# 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;
hey ben can you modify this so it could be seen on tos mobile watchlist? thank you!
 
I have found a thread at another site where they have posted the TOS script but it has too many typo problems (mainly cut and paste issues), was wondering if anybody could clean that up. The 6 scripts have to do with ATR and using ATR for projections. https://futures.io/thinkorswim/5576...m-trading-platform-every-day-thinkorswim.html
Code 1
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);


304591.png
 
Code 2 For ATR Projections: from the website . https://futures.io/thinkorswim/5576...m-trading-platform-every-day-thinkorswim.html

Code:
#Possibility Move by ATR Ver.1.03
#by thetrader.top
#Potential price movement by ATR

declare once_per_bar;
declare hide_on_daily;

input length = 14;
input ShowATR = No;
def ATR = Average(TrueRange(high(period = “DAYâ€), close(period = “DAYâ€), low(period = “DAYâ€)), length )[1];
AddLabel (ShowATR, “ATR(“+length+â€) “ + Round(ATR,2), Color.GRAY);
def newDay = SecondsFromTime(0930)==0;

def DayHigh = if newDay then High else if High[1] > DayHigh[1] then High[1] else DayHigh[1];
def DayLow = if newDay then Low else if Low[1] < DayLow[1] then Low[1] else DayLow[1];

plot UpLevel = If(GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN, DayLow + ATR, Double.NaN);
plot DownLevel = If(GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN,DayHigh — ATR, Double.NaN);
UpLevel.SetDefaultColor (Color.GRAY);
UpLevel.SetPaintingStrategy(PaintingStrategy.LINE);
UpLevel.SetStyle(Curve.LONG_DASH);
DownLevel.SetDefaultColor(Color.GRAY);
DownLevel.SetPaintingStrategy(PaintingStrategy.LINE);
DownLevel.SetStyle(Curve.LONG_DASH);

plot UpLevel4 = If(GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN, (DayLow + (4*ATR)), Double.NaN);
plot DownLevel4 = If(GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN,(DayHigh — (4*ATR)), Double.NaN);
UpLevel4.SetDefaultColor (Color.blue);
UpLevel4.SetPaintingStrategy(PaintingStrategy.LINE);
UpLevel4.SetStyle(Curve.LONG_DASH);
DownLevel4.SetDefaultColor(Color.blue);
DownLevel4.SetPaintingStrategy(PaintingStrategy.LINE);
DownLevel4.SetStyle(Curve.LONG_DASH);
304594.png
 
Last edited:
@Jon436 this looks like a very useful script for stop and target placement. When I pasted in the script from your 2nd post, I got a number of errors. How did you get it to plot like in your picture from the same post? I think there might be some problem with the code.
 
INDICATOR : https://tos.mx/O6FbYwT
################################
#REMASTERED by Cwparker23 #
################################
#-----------------
#DISCLAIMER
#-----------------
#I am not a certified financial advisor. The content of this page/site and tools are for informational purposes only and does not constitute financial or legal advice. Under no circumstances will the author be responsible for errors or use of this tool and site. User assumes all risks.

declare upper;
input higherTimeFrame = AggregationPeriod.day;
input averageType = AverageType.WILDERS;
input AtrAvgLength = 10;

DEF DL = low(period = higherTimeFrame );
DEF DH = high(period = higherTimeFrame );
DEF DC = CLOSE(period = higherTimeFrame );

DEF PREvLOW = low(period = higherTimeFrame )[1];
DEF PREvHIGH = high(period = higherTimeFrame )[1];
DEF PREvCLose = close(period = higherTimeFrame )[1];
PLOT DAY_OPEN = OPEN(period = higherTimeFrame );
DAY_OPEN.SetDefaultColor(Color.WHITE);
DAY_OPEN.SetLineWeight(3);
DAY_OPEN.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

DEF ATR = MovingAverage(averageType, TrueRange(PREvHIGH, PREvCLose , PREvLOW), AtrAvgLength);

DEF TodayHigh = MovingAverage(averageType, DH, AtrAvgLength);
DEF TodayLow = MovingAverage(averageType, DL, AtrAvgLength);

DEF HighPV = MovingAverage(averageType, PREvHIGH, AtrAvgLength);
DEF LowPV = MovingAverage(averageType, PREvLOW, AtrAvgLength);

def DTR = HighPV - LowPV;

def DTRpct = Round((DTR / ATR) * 100,2);

DEF ATR2 = MovingAverage(averageType, TrueRange(DH, DC , DL), AtrAvgLength);
def DTR2 = TodayHigh - TodayLow;
def DTRpct2 = Round((DTR2 / ATR2) * 100,2);


AddLabel (yes, "DTR " + Round (DTR2 , 2) + " vs ATR " + round (ATR2,2)+ " " + round (DTRpct2,0) + "%", (if DTRpct2 <= 70 then Color.GREEN else if DTRpct2 >= 90 then Color.RED else Color.ORANGE));


PLOT HO = DAY_OPEN + DTR;
PLOT LO = DAY_OPEN - DTR;

def range = HO - LO;

INPUT LEVEL1 = .786;
INPUT LEVEL2 = .618;
INPUT LEVEL3 = .382;
INPUT LEVEL4 = .286;



PLOT LEVEL_1 = LO + (LEVEL1 * range);
PLOT LEVEL_2 = LO + (LEVEL2 * range);
PLOT LEVEL_3 = LO + (LEVEL3 * range);
PLOT LEVEL_4 = LO + (LEVEL4 * range);

 
Last edited by a moderator:
INDICATOR : https://tos.mx/O6FbYwT
################################
#REMASTERED by Cwparker23 #
################################
#-----------------
#DISCLAIMER
#-----------------
#I am not a certified financial advisor. The content of this page/site and tools are for informational purposes only and does not constitute financial or legal advice. Under no circumstances will the author be responsible for errors or use of this tool and site. User assumes all risks.

declare upper;
input higherTimeFrame = AggregationPeriod.day;
input averageType = AverageType.WILDERS;
input AtrAvgLength = 10;

DEF DL = low(period = higherTimeFrame );
DEF DH = high(period = higherTimeFrame );
DEF DC = CLOSE(period = higherTimeFrame );

DEF PREvLOW = low(period = higherTimeFrame )[1];
DEF PREvHIGH = high(period = higherTimeFrame )[1];
DEF PREvCLose = close(period = higherTimeFrame )[1];
PLOT DAY_OPEN = OPEN(period = higherTimeFrame );
DAY_OPEN.SetDefaultColor(Color.WHITE);
DAY_OPEN.SetLineWeight(3);
DAY_OPEN.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

DEF ATR = MovingAverage(averageType, TrueRange(PREvHIGH, PREvCLose , PREvLOW), AtrAvgLength);

DEF TodayHigh = MovingAverage(averageType, DH, AtrAvgLength);
DEF TodayLow = MovingAverage(averageType, DL, AtrAvgLength);

DEF HighPV = MovingAverage(averageType, PREvHIGH, AtrAvgLength);
DEF LowPV = MovingAverage(averageType, PREvLOW, AtrAvgLength);

def DTR = HighPV - LowPV;

def DTRpct = Round((DTR / ATR) * 100,2);

DEF ATR2 = MovingAverage(averageType, TrueRange(DH, DC , DL), AtrAvgLength);
def DTR2 = TodayHigh - TodayLow;
def DTRpct2 = Round((DTR2 / ATR2) * 100,2);


AddLabel (yes, "DTR " + Round (DTR2 , 2) + " vs ATR " + round (ATR2,2)+ " " + round (DTRpct2,0) + "%", (if DTRpct2 <= 70 then Color.GREEN else if DTRpct2 >= 90 then Color.RED else Color.ORANGE));


PLOT HO = DAY_OPEN + DTR;
PLOT LO = DAY_OPEN - DTR;

def range = HO - LO;

INPUT LEVEL1 = .786;
INPUT LEVEL2 = .618;
INPUT LEVEL3 = .382;
INPUT LEVEL4 = .286;



PLOT LEVEL_1 = LO + (LEVEL1 * range);
PLOT LEVEL_2 = LO + (LEVEL2 * range);
PLOT LEVEL_3 = LO + (LEVEL3 * range);
PLOT LEVEL_4 = LO + (LEVEL4 * range);

@Cwparker23 this is nice, I'm interested in your volume indicator labels? Are they accurate or are they misleading like the others? Cant seem to find it to try it out
 
@MerryDay the code he's trying to fix is for atr price movement plot, the one you referred back to is the script for the atr/atrplay/ etc, theyre different codes just don't look like it but they are. This one is set for a 15 minute aggregated time frame the other doesn't have a timeframe, just look at the screenshot 2 totally different scripts or maybe I'm trippin lol, I put both codes side by side and theyre different. I'm not a scripter but I think theyre different.
 
Last edited by a moderator:
@MerryDay the code he's trying to fix is for atr price movement plot, the one you referred back to is the script for the atr/atrplay/ etc, theyre different codes just don't look like it but they are. This one is set for a 15 minute aggregated time frame the other doesn't have a timeframe, just look at the screenshot 2 totally different scripts or maybe I'm trippin lol, I put both codes side by side and theyre different. I'm not a scripter but I think theyre different.
I only fixed the atr play script. It was the only script that he had reported errors. If other scripts have errors, you will need to provide images of what the errors are and what you want to have fixed.
 
@Cwparker23 this is nice, I'm interested in your volume indicator labels? Are they accurate or are they misleading like the others? Cant seem to find it to try it out
The volume labels are based off the difference between buying and selling volume. You should be able to find them under buying and selling pressure indicator. As far as accuracy they simply take the percentage of the candle that is considered buying: ((close - low)/(high - low))*volume and selling: ((high - close)/(high - low))
@Cwparker23 this is nice, I'm interested in your volume indicator labels? Are they accurate or are they misleading like the others? Cant seem to find it to try it out
*volume
@Cwparker23 this is nice, I'm interested in your volume indicator labels? Are they accurate or are they misleading like the others? Cant seem to find it to try it out
The labels are based on the buy sell pressure volume indicator on the site. They simply take the percentage of the candle that is considered buying: ((close - low)/(high - low))*volume and selling: (high - close)/(high - low)*volume. I averaged the buying and selling and If buying average volume was greater than the selling average volume then the label would be green and vice versa it will be RED.
 
The volume labels are based off the difference between buying and selling volume. You should be able to find them under buying and selling pressure indicator. As far as accuracy they simply take the percentage of the candle that is considered buying: ((close - low)/(high - low))*volume and selling: ((high - close)/(high - low))

*volume

The labels are based on the buy sell pressure volume indicator on the site. They simply take the percentage of the candle that is considered buying: ((close - low)/(high - low))*volume and selling: (high - close)/(high - low)*volume. I averaged the buying and selling and If buying average volume was greater than the selling average volume then the label would be green and vice versa it will be RED.
@Cwparker23 Looked for the volume indicator but didn't see one like this one that you have to try out. Do you mind sharing your script so I can give it a try?
 
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:

X0q1Npm.png


Indicator code:

Code:
# 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));

Shareable link: https://tos.mx/Qimvmh
Thanks, Simple and handy ! Best wishes.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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