##### Begin Code #####
# SD_ATR_Lines
# Scott Da####
# Version: 01
# Original: January 16, 2021
# Last Mod: January 16, 2021
declare upper;
input aggregationPeriod = AggregationPeriod.MIN;
input price=close;
input ATRValue = 5;
input averageType = AverageType.WILDERS;
input StopFactor = 2;
input offset=0;
input LineLength = 10;
input ShowLabel = yes;
def open = open(period = aggregationPeriod);
def high = high(period = aggregationPeriod);
def low = low(period = aggregationPeriod);
def close = close(period = aggregationPeriod);
def ATR = MovingAverage(averageType, TrueRange(high, close, low), ATRValue);
# Top Line
def sma1 = SimpleMovingAvg((Close + (ATR*StopFactor)), 1, LineLength);
rec line1 = if IsNaN(sma1) then line1[1] else sma1[offset];
plot ATRLine1=if isnan(sma1) then line1 else double.nan;
ATRLine1.setpaintingStrategy(paintingStrategy.LINE);
ATRLine1.setlineWeight(1);
ATRLine1.setdefaultColor(color.yellow);
ATRLine1.hideBubble();
# Bottom Line
def sma2 = SimpleMovingAvg((Close - (ATR*StopFactor)), 1, LineLength);
rec line2 = if IsNaN(sma2) then line2[1] else sma2[offset];
plot ATRLine2=if isnan(sma2) then line2 else double.nan;
ATRLine2.setpaintingStrategy(paintingStrategy.LINE);
ATRLine2.setlineWeight(1);
ATRLine2.setdefaultColor(color.yellow);
ATRLine2.hideBubble();
##### End Code #####