```
# ATR Daily Range
# tomsk
# 12.17.2019
# V1.0 - 12.16.2019 - tomsk - Initial release ATR Daily Range
# V1.1 - 12.16.2019 - tomsk - Added performance relative to ATR range
# V1.2 - 12.17.2019 - tomsk - Added plot lines for ATR High/Low on the chart
# Displays ATR High/Low thresholds relative to daily open
input length = 14;
input averageType = AverageType.WILDERS;
def o = open(period = AggregationPeriod.DAY);
def h = high(period = AggregationPeriod.DAY);
def l = low(period = AggregationPeriod.DAY);
def c = close(period = AggregationPeriod.DAY);
def R = (c - l) / (h - l);
def DTR = h - l;
def ATRD = MovingAverage(averageType, TrueRange(h, c, l), length);
def ATRH = o + ATRD;
def ATRL = o - ATRD;
def DTRpct = Round((DTR / ATRD), 0);
AddLabel(close > 0, Concat( "ATR: ", round(ATRD) * 10000), Color.GREEN);
#AddLabel(1, "ATR Daily High/Low Level = [ " + Round(ATRH,2) + " / " + Round(ATRL,2) + " ]", Color.PINK);
#AddLabel(1, "["+AsPercent(r)+"]", Color.green);
def LBN = if IsNaN(close[-1]) and !IsNaN(close) then BarNumber() else Double.NaN;
plot ATR_High = if BarNumber() >= HighestAll(LBN)
then HighestAll(if IsNaN(close[-1]) then ATRH else Double.NaN)
else Double.NaN;
ATR_High.SetLineWeight(2);
ATR_High.SetDefaultColor(Color.GREEN);
plot ATR_Low = if BarNumber() >= HighestAll(LBN)
then HighestAll(if IsNaN(close[-1]) then ATRL else Double.NaN) else Double.NaN;
def mid = (h + l) / 2;
input showOnlyLastPeriod = yes;
plot ATR_H;
plot ATR_L;
if showOnlyLastPeriod and !IsNaN(close(period = AggregationPeriod.DAY)[-1]) {
ATR_H = Double.NaN;
ATR_L = Double.NaN;
} else {
ATR_L = mid - (ATRD / 2);
ATR_H = mid + (ATRD / 2);
}
ATR_H.SetDefaultColor(Color.GREEN);
ATR_L.SetDefaultColor(Color.GREEN);
ATR_Low.SetLineWeight(2);
ATR_Low.SetDefaultColor(Color.GREEN);
# End ATR Daily Range
```