Displays multiples of current ATR as labels on your chart. Helpful for quick reference if using for target/stop levels.
# ATR Label Only (Upper Study)
declare upper;
input atrLength = 14;
input smoothingType = AverageType.WILDERS;
input labelRed = 200;
input labelGreen = 200;
input labelBlue = 200;
DefineGlobalColor("LabelColor", CreateColor(labelRed, labelGreen, labelBlue));
# Calculate ATR using chart's current timeframe
def atr = MovingAverage(
smoothingType,
TrueRange(high, close, low),
atrLength
);
# ATR multiples
def atrHalf = atr * 0.5;
def atrOne = atr * 1.0;
def atrOnePointFive = atr * 1.5;
def atrThree = atr * 3.0;
# Labels
AddLabel(
yes,
"0.5 × ATR: " + AsText(atrHalf, NumberFormat.TWO_DECIMAL_PLACES),
GlobalColor("LabelColor")
);
AddLabel(
yes,
"1 × ATR: " + AsText(atrOne, NumberFormat.TWO_DECIMAL_PLACES),
GlobalColor("LabelColor")
);
AddLabel(
yes,
"1.5 × ATR: " + AsText(atrOnePointFive, NumberFormat.TWO_DECIMAL_PLACES),
GlobalColor("LabelColor")
);
AddLabel(
yes,
"3 × ATR: " + AsText(atrThree, NumberFormat.TWO_DECIMAL_PLACES),
GlobalColor("LabelColor")
);