# https://usethinkscript.com/threads/daily-atr-support-resistance-lines-for-thinkorswim.3633/
input showplots = {default all, current_only, prior_only};
input showcurrentonly = yes;
input ATRperiod = 14;
input averageType = AverageType.WILDERS;
input BasePeriod = AggregationPeriod.DAY;
input ATRMultiplier = 1.0;
input ATRMultiplier2 = 2.0;
input ATRMultiplier3 = 3.0;
input ATRMultiplier4 = 4.0;
def ATR = MovingAverage(averageType, TrueRange(high(period = ”DAY”)[1], close(period = ”DAY”)[1], low(period = ”DAY”)[1]), ATRperiod);
def DailyClose = if showplots == showplots.prior_only and GetDay() == GetLastDay() then Double.NaN else if showplots == showplots.current_only and GetDay() != GetLastDay() then Double.NaN else close(period = ”DAY”)[1];
plot HighATR = DailyClose + ATR * ATRMultiplier;
plot LowATR = DailyClose - ATR * ATRMultiplier;
plot HighATR2 = DailyClose + ATR * ATRMultiplier2;
plot LowATR2 = DailyClose - ATR * ATRMultiplier2;
plot HighATR3 = DailyClose + ATR * ATRMultiplier3;
plot LowATR3 = DailyClose - ATR * ATRMultiplier3;
plot HighATR4 = DailyClose + ATR * ATRMultiplier4;
plot LowATR4 = DailyClose - ATR * ATRMultiplier4;
HighATR.SetDefaultColor(color = Color.RED);
HighATR2.SetDefaultColor(color = Color.RED);
HighATR3.SetDefaultColor(color = Color.RED);
HighATR4.SetDefaultColor(color = Color.RED);
LowATR.SetDefaultColor(color = Color.GREEN);
LowATR2.SetDefaultColor(color = Color.GREEN);
LowATR3.SetDefaultColor(color = Color.GREEN);
LowATR4.SetDefaultColor(color = Color.GREEN);
HighATR.SetPaintingStrategy(PaintingStrategy.DASHES);
HighATR2.SetPaintingStrategy(PaintingStrategy.DASHES);
HighATR3.SetPaintingStrategy(PaintingStrategy.DASHES);
HighATR4.SetPaintingStrategy(PaintingStrategy.DASHES);
LowATR.SetPaintingStrategy(PaintingStrategy.DASHES);
LowATR2.SetPaintingStrategy(PaintingStrategy.DASHES);
LowATR3.SetPaintingStrategy(PaintingStrategy.DASHES);
LowATR4.SetPaintingStrategy(PaintingStrategy.DASHES);
def DC = close(period = ”DAY”)[1];
def HighATR_ = DC + ATR * ATRMultiplier;
def LowATR_ = DC - ATR * ATRMultiplier;
def HighATR2_ = DC + ATR * ATRMultiplier2;
def LowATR2_ = DC - ATR * ATRMultiplier2;
#AddLabel(visible = yes, text = "ATR: " + Round(ATR / close * 100, 2) + "%", color = Color.LIGHT_GRAY);
AddLabel(visible = yes, text = "S1: " + Round(LowATR_, 2), color = Color.GREEN);
AddLabel(visible = yes, text = "R1: " + Round(HighATR_, 2), color = Color.RED);
AddLabel(visible = yes, text = "S2: " + Round(LowATR2_, 2), color = Color.GREEN);
AddLabel(visible = yes, text = "R2: " + Round(HighATR2_, 2), color = Color.RED);
;