# Add chart label for Average True Range (ATR)

Category:
0
0

Hello Hahn,

I would just like a study indicator that places a rectangular label on the top left side of the chart that shows the current bar’s ATR in just one square box. The box should change colors depending on the values Average True Range (ATR).

If the ATR is above 25 cent then box indicator background should change to color green

If the ATR is above is 15-20 cent then box indicator background should change to color yellow

If ATR is below 15 cent, color should be white

**Keep in mind, my TOS background is black

j

Would you please copy/paste the entire code right here as I don’t know anything about coding?

You are the best

Marked as spam
Posted by (Questions: 22, Answers: 63)
Asked on April 27, 2018 4:28 pm
3212 views
 ▲ 0 ▼ Before providing a solution I want to make sure you understand the scope of your request. The value of the ATR is influenced by the average price of a given stock. For instance the ATR value of a 1,000 dollar stock will be roughly 100 times greater than the ATR value of a 10 dollar stock. Therefore, the use of a fixed value of 25, 20 and 15 has extremely limited utility. You should rather consider a value of the ATR expressed as a percent of the average stock price. (Pete Hahn at April 27, 2018 7:35 pm)
 ▲ 0 ▼ I understand,  will be using the ATR for stocks between 1 dollar and 10 dollars so the changes in cent are important to me. I will be setting this ATR chart label to be used on 1 and 5-minute charts.    I want to use this chart label to give the real-time ATR of a stock for the current 1 or 5 minute candle. (Juan Banderas at April 29, 2018 8:22 am)
0

After getting clarification on this request we have the following code to accomplish the goal:

```input length = 14; input averageType = AverageType.WILDERS; plot ATR = MovingAverage(averageType, TrueRange(high, close, low), length); AddLabel(yes, ATR, if ATR < 0.25 then Color.GREEN else if ATR > 0.15 then Color.YELLOW else Color.WHITE);```

Marked as spam
Posted by (Questions: 37, Answers: 4102)
Answered on April 29, 2018 9:07 am
 ▲ 0 ▼ Is it possible to modify this code to show the Daily ATR regardless of the chart time-frame I have open, i.e. show the Daily ATR when I'm on a 5min chart? (Scott at October 24, 2019 7:47 am)
 ▲ 0 ▼ Pretty sure that question has already been asked and answered: https://www.hahn-tech.com/ans/modify-chart-label-wording-based-on-daily-atr/ (Pete Hahn at October 24, 2019 12:48 pm)
 ▲ 0 ▼ Thank you (Scott at October 24, 2019 3:04 pm)