# Question about how APTR is calculated.

#### bigmit2011

##### New member
I was looking through the documentation on APTR,

and don't understand what is meant by this part:

"divded by the middle value"

What middle value is the documentation referring to ?

Here is the full quote:

"Much like the standard ATR, the percentage version uses true range as the principal variable. In the APTR, the true range is divided by its own middle value, which yields the target percent ratio. This ratio is then smoothed by a moving average of the "specified type, Wilder's smoothing being the default.

Here is the link to the documentation:

https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/A-B/APTR

Thank you.

Solution
You can view the code of studies and strategies by clicking on the script icon to the left of the title. Opening the code shows the following.

Ruby:
#
# TD Ameritrade IP Company, Inc. (c) 2015-2021
#

declare lower;

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

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

plot APTR = MovingAverage(averageType, ptr, length);
APTR.SetDefaultColor(GetColor(8));

The reference to "its own middle value" in the documentation is "(bottom + tr / 2)" in the code, which is the lowest of either the current or prior bar plus half of the true range.
You can view the code of studies and strategies by clicking on the script icon to the left of the title. Opening the code shows the following.

Ruby:
#
# TD Ameritrade IP Company, Inc. (c) 2015-2021
#

declare lower;

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

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

plot APTR = MovingAverage(averageType, ptr, length);
APTR.SetDefaultColor(GetColor(8));

The reference to "its own middle value" in the documentation is "(bottom + tr / 2)" in the code, which is the lowest of either the current or prior bar plus half of the true range.

Last edited:

87k+ Posts
370 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?