ATR Normalized

A

alvissome

New member
Hi there I'm new here and I'm trying to come out a thinkscript similar to
in which Adam Khoo uses it in combination with William R to determine market bottom. However I couldn't quite get the thinkscript portion of it, anyone is able to offer any insights that comes close to his?
 
inthefutures

inthefutures

Active member
what part don't you get the normalized atr?
 
A

alvissome

New member
The thinkscript, the thinkorswim default only has ATR but not the normalized one. I tried writing but came nowhere near what he’s seeing.
 
inthefutures

inthefutures

Active member
i will take a look at creating one, see what i get
 
inthefutures

inthefutures

Active member
Code:
declare lower;

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

def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);

plot normal =( atr/close * 1000);
 
inthefutures

inthefutures

Active member
could easily be all coded together with trigger arrows will look at that tomorrow
 
inthefutures

inthefutures

Active member
I tested the idea and it has only found 2 times in 15 years it would have triggered, Tried running it on lower time frames than a weekly and it is of no value so not sure worth going any further
 
L

ljyeang

New member
I tested the idea and it has only found 2 times in 15 years it would have triggered, Tried running it on lower time frames than a weekly and it is of no value so not sure worth going any further
don't understand why it's different than tradingview outcome
 
inthefutures

inthefutures

Active member
what normalized atr are you using in tradingview
 
B

btran

New member
Hi @inthefutures,

How do you rewrite the tradingview's code below in thinkorswim? Thank you in advance for your help. I am not too familiar with thinkscript and couldn't get it to work.

Code:
study(title="ATR Percent Rank", shorttitle="ATR Normalized", overlay=false)

source = close

atrlen = input(13, minval=1, title = "ATR Length")

lookback = input(52, minval=1, title ="Percent Rank Lookback")

atrp = percentrank(atr(atrlen),lookback)

plot(atrp, color=#ff9800, transp=0)
I think I came close, but it does not like my plot statement.

Code:
study(title="ATR Percent Rank", shorttitle="ATR Normalized", overlay=false)
;
source = close
;
atrlen = 13
;
lookback = 52
;

atrp = percentrank(atr(atrlen),lookback);

plot atrp (color=#ff9800);
Only work for Year 2009.
 
Last edited by a moderator:
K

Kimberly

New member
My TOS doesn't like the last line, so I can't click "ok"
 
horserider

horserider

Well-known member
VIP
@Kimberly Do not worry about it . None of that is proper thinkscript code.
 
D

diazlaz

Well-known member
2019 Donor
VIP
Per the requests in this post; I've created a version of this study. I think it's quite helpful in classifying the volatility of the market:



Ruby:
#APTR Percentile Rank for ThinkorSwim Version 1.0
#
#VERSION
# 2020.04.11 V1.0 @diazlaz - Initial Release
#
#
#INSTRUCTION
#ATR PercentileRank - Great For Showing Market Bottoms.
#
#When Increased Volatility to the Downside Reaches Extreme Levels
#it’s Usually a Sign of a Market Bottom.
#
#This Indicator Takes the ATR and uses a different LookBack Period
#to calculate the Percentile Rank of ATR Which is a Great Way To
#Calculate Volatility
#
#

declare lower;

input length = 10;
input length2 = 100; #no. of Bars the PercentileRank uses to Calculate Rank
input averageType = AverageType.WILDERS;
input paintBars = yes;
input showLabels = yes;

#LABELS
AddLabel (showLabels, "APTR Percentile Rank for ThinkorSwim Version 1.0", COLOR.ORANGE);

#APTR
def bottom = Min(close[1], low);
def tr = TrueRange(high, close, low);
def ptr = tr / (bottom + tr / 2) * 100;
def APTR = MovingAverage(averageType, ptr, length);

#Percentile Rank Calculation
def percentRankCount = fold i = 1 to length2 + 1 with count = 0
do
  if APTR[0] > APTR[i] then
    count + 1
  else
    count;
def percentRank = Round( percentRankCount / length2 * 100.0, 0);

#PLOTS
plot pATRRank = percentRank;
pATRRank.SetLineWeight(2);
pATRRank.SetDefaultColor(GetColor(8));

plot p25 = 25;
plot p50 = 50;
plot p75 = 75;

p25.setDefaultColor(COLOR.DARK_GRAY);
p25.HideTitle();
p25.HideBubble();

p50.setDefaultColor(COLOR.DARK_GRAY);
p50.HideTitle();
p50.HideBubble();

p75.setDefaultColor(COLOR.DARK_GRAY);
p75.HideTitle();
p75.HideBubble();

#END Of APTR Percentile Rank for ThinkorSwim Version 1.0
 
N

Nate67

New member
I have the same problem. The thinkorswim platform doesn't offer a "normalized" option... Only Wilder, Simple, Exponential etc...

Is there a way to add it to the mobile app somehow? Or did anyone found a solution?

Thanks! :)
 

Similar threads

Top