# ATRpivots
# Question from Rob3; plots horizontal lines on daily candle that are at the open and above and below in increments of ATR * 0.125. The open is restricted to the Day aggregation period.
input price = open;
input length = 14;
input averageType = AverageType.WILDERS;
input ATRfraction = 0.125;
def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);
plot LineAtOpen = open (period = AggregationPeriod.DAY);
plot UpperPivot1 = LineAtOpen + (ATR * ATRfraction);
plot UpperPivot2 = LineAtOpen + (ATR * ATRfraction * 2);
plot UpperPivot3 = LineAtOpen + (ATR * ATRfraction * 3);
plot UpperPivot4 = LineAtOpen + (ATR * ATRfraction * 4);
plot UpperPivot5 = LineAtOpen + (ATR * ATRfraction * 5);
plot UpperPivot6 = LineAtOpen + (ATR * ATRfraction * 6);
plot UpperPivot7 = LineAtOpen + (ATR * ATRfraction * 7);
plot UpperPivot8 = LineAtOpen + (ATR * ATRfraction * 8);
plot LowerPivot1 = LineAtOpen - (ATR * ATRfraction);
plot LowerPivot2 = LineAtOpen - (ATR * ATRfraction * 2);
plot LowerPivot3 = LineAtOpen - (ATR * ATRfraction * 3);
plot LowerPivot4 = LineAtOpen - (ATR * ATRfraction * 4);
plot LowerPivot5 = LineAtOpen - (ATR * ATRfraction * 5);
plot LowerPivot6 = LineAtOpen - (ATR * ATRfraction * 6);
plot LowerPivot7 = LineAtOpen - (ATR * ATRfraction * 7);
plot LowerPivot8 = LineAtOpen - (ATR * ATRfraction * 8);
LineAtOpen.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LineAtOpen.SetDefaultColor(Color.YELLOW);
LineAtOpen.SetLineWeight(1);
UpperPivot1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot1.SetDefaultColor(Color.BLUE);
UpperPivot1.SetLineWeight(1);
UpperPivot2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot2.SetDefaultColor(Color.BLUE);
UpperPivot2.SetLineWeight(1);
UpperPivot3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot3.SetDefaultColor(Color.BLUE);
UpperPivot3.SetLineWeight(1);
UpperPivot4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot4.SetDefaultColor(Color.BLUE);
UpperPivot4.SetLineWeight(1);
UpperPivot5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot5.SetDefaultColor(Color.BLUE);
UpperPivot5.SetLineWeight(1);
UpperPivot6.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot6.SetDefaultColor(Color.BLUE);
UpperPivot6.SetLineWeight(1);
UpperPivot7.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot7.SetDefaultColor(Color.BLUE);
UpperPivot7.SetLineWeight(1);
UpperPivot8.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot8.SetDefaultColor(Color.BLUE);
UpperPivot8.SetLineWeight(1);
LowerPivot1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot1.SetDefaultColor(Color.RED);
LowerPivot1.SetLineWeight(1);
LowerPivot2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot2.SetDefaultColor(Color.RED);
LowerPivot2.SetLineWeight(1);
LowerPivot3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot3.SetDefaultColor(Color.RED);
LowerPivot3.SetLineWeight(1);
LowerPivot4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot4.SetDefaultColor(Color.RED);
LowerPivot4.SetLineWeight(1);
LowerPivot5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot5.SetDefaultColor(Color.RED);
LowerPivot5.SetLineWeight(1);
LowerPivot6.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot6.SetDefaultColor(Color.RED);
LowerPivot6.SetLineWeight(1);
LowerPivot7.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot7.SetDefaultColor(Color.RED);
LowerPivot7.SetLineWeight(1);
LowerPivot8.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot8.SetDefaultColor(Color.RED);
LowerPivot8.SetLineWeight(1);