# ATR on higher time frame

#### vanwooten

##### New member
Can I get the ATR for a higher time frame chart than the chart that I am on. So if I'm on a one minute chart, I am looking for the two minute ATR.

Solution
You can't specify the aggregation period in the built-in ATR() function. But this seems to work:
Code:
``````declare lower;

input length = 14;

input period = AggregationPeriod.TWO_MIN;
input type = AverageType.WILDERS;

def h = high(period = period);
def l = low(period = period);
def o = open(period = period);
def c = close(period = period);

def x = h - l;
def y = absValue(h - c[1]);
def z = absValue(l - c[1]);

def tr = max(max(x, y), z);

def barnum = BarNumber();

def atr = if barnum == length
then (1 / barnum) * sum(tr, length)
else if barnum < length then double.nan
else (atr[1] + tr) / length;

def myatr = atr;
plot avg = WildersAverage(myatr);``````

-mashume
You can't specify the aggregation period in the built-in ATR() function. But this seems to work:
Code:
``````declare lower;

input length = 14;

input period = AggregationPeriod.TWO_MIN;
input type = AverageType.WILDERS;

def h = high(period = period);
def l = low(period = period);
def o = open(period = period);
def c = close(period = period);

def x = h - l;
def y = absValue(h - c[1]);
def z = absValue(l - c[1]);

def tr = max(max(x, y), z);

def barnum = BarNumber();

def atr = if barnum == length
then (1 / barnum) * sum(tr, length)
else if barnum < length then double.nan
else (atr[1] + tr) / length;

def myatr = atr;
plot avg = WildersAverage(myatr);``````

-mashume

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