KingsOp
New member
In the following code I have 2 plots to indicate the ATR high and low based on the current candle projected into the next candles timeframe. I mostly use this on a day timeframe so I know what a move based on yesterday's close will look like if it is greater than average. The problem is it also shows every day up to that point so there are a LOT of dots (that's what I have them drawn as) on the chart. I'd like to be able to limit the number of dots from the past showing. Hope I'm explaining myself well. So say I only want to see the past three days worth of data, how do I limit the plot to those kind of parameters instead of for the whole history of the chart?
Code:
input time = AggregationPeriod.DAY;
#hint time: enter the desired chart timeframe
input length = 14;
#hint length: enter the desired average length
input averageType = AverageType.WILDERS;
#hint averageType: enter the desired average calculation method
def ATR = MovingAverage(averageType, TrueRange(high(period = time), close(period = time), low(period = time)), length);
def ATRUP = close(period = time) + ATR;
def ATRDN = close(period = time) - ATR;
plot UP = ATRUP[1];
plot DN = ATRDN[1];
UP.SetDefaultColor(GetColor(8));
DN.SetDefaultColor(GetColor(8));
#hint: This indicator will plot the ATR levels for the given chart timeframe projected from the close of the last bar onto the next bar. Designed intentionally for the DAY timeframe but will work in any timeframe.