This is a modified conversion of the RMA ATR Bands which is a directional volatility trend indicator built around a smoothed RMA baseline combined with asymmetric ATR expansion bands.
Unlike traditional symmetric ATR envelopes, the indicator uses independent upper and lower ATR multipliers to create adaptive directional filtering and trend regime detection. This allows the system to respond differently to bullish and bearish volatility conditions while maintaining a smoother baseline structure through RMA smoothing.
Bullish regime:
• Price closes above the upper ATR expansion band
Bearish regime:
• Price closes below the lower ATR expansion band
I added and modified the upper and lower bands along with dots for extreme conditions.
Original code: https://www.tradingview.com/script/xN8JwiZI-RMA-ATR-Bands/
Here is /MES on the 10 minute chart.
Here is the LOWER INDICATOR:
Unlike traditional symmetric ATR envelopes, the indicator uses independent upper and lower ATR multipliers to create adaptive directional filtering and trend regime detection. This allows the system to respond differently to bullish and bearish volatility conditions while maintaining a smoother baseline structure through RMA smoothing.
Bullish regime:
• Price closes above the upper ATR expansion band
Bearish regime:
• Price closes below the lower ATR expansion band
I added and modified the upper and lower bands along with dots for extreme conditions.
Original code: https://www.tradingview.com/script/xN8JwiZI-RMA-ATR-Bands/
Here is /MES on the 10 minute chart.
Code:
#
# RMA_ATR_Bands
# Inspired and converted from Pine Script by SchizoQuant https://www.tradingview.com/v/xN8JwiZI/
# Converted and modified by Chewie 6/4/2026
declare upper;
# ─── USER INPUTS ───────────────────────────────────────────────────────────────
input alerts = yes;
input maSrc = FundamentalType.HIGH; # RMA source (HIGH matches Pine default)
input maLength = 14; # RMA length
input atrLength = 13; # ATR length
input upperMult = 0.4; # Upper ATR multiplier
input upperMult2 = 1.6; # Upper ATR multiplier
input upperMult3 = 3.0; # Upper ATR multiplier
input lowerMult = 1.6; # Lower ATR multiplier
input lowerMult2 = 3.0; # Lower ATR multiplier
input showATRBands = yes; # Show ATR bands
input colorBars = yes; # Color price bars
input dots = yes;
input showSignals = yes; # Show long/short signals
input showBubble = no; # Show long/short signals
# ─── SOURCE ────────────────────────────────────────────────────────────────────
def src = Fundamental(maSrc);
# ─── RMA (Wilder's Moving Average) ─────────────────────────────────────────────
def ma = WildersSmoothing(src, maLength);
# ─── ATR BANDS ─────────────────────────────────────────────────────────────────
def atr = Average(TrueRange(high, close, low), atrLength);
def upperLine = ma + atr * upperMult;
def upperLine2 = ma + atr * upperMult2;
def upperLine3 = ma + atr * upperMult3;
def lowerLine = ma - atr * lowerMult;
def lowerLine2 = ma - atr * lowerMult2;
# ─── TREND LOGIC ───────────────────────────────────────────────────────────────
def isLong = close > upperLine;
def isShort = close < lowerLine;
def trend;
if isLong {
trend = 1;
} else if isShort {
trend = -1;
} else {
trend = trend[1]; # hold previous state (matches Pine's var int)
}
def longSignal = trend == 1 and trend[1] != 1;
def shortSignal = trend == -1 and trend[1] != -1;
# ─── COLORS ────────────────────────────────────────────────────────────────────
DefineGlobalColor("Long", CreateColor(57, 255, 20));
DefineGlobalColor("Short", CreateColor(138, 50, 255));
DefineGlobalColor("Neutral", Color.GRAY);
# ─── PLOTS ─────────────────────────────────────────────────────────────────────
plot RMALine = ma;
RMALine.SetLineWeight(2);
RMALine.AssignValueColor(
if trend == 1 then GlobalColor("Long")
else if trend == -1 then GlobalColor("Short")
else GlobalColor("Neutral")
);
RMALine.SetDefaultColor(Color.GRAY);
plot UpperBand = upperLine;
UpperBand.SetLineWeight(1);
UpperBand.AssignValueColor(
if trend == 1 then GlobalColor("Long")
else if trend == -1 then GlobalColor("Short")
else GlobalColor("Neutral")
);
UpperBand.SetDefaultColor(Color.GRAY);
plot UpperBand2 = if showATRBands then upperLine2 else Double.NaN;
UpperBand2.SetLineWeight(1);
UpperBand2.AssignValueColor(
if trend == 1 then GlobalColor("Long")
else if trend == -1 then GlobalColor("Short")
else GlobalColor("Neutral")
);
UpperBand2.SetDefaultColor(Color.GRAY);
plot UpperBand3 = if showATRBands then upperLine3 else Double.NaN;
UpperBand3.SetLineWeight(1);
UpperBand3.AssignValueColor(
if trend == 1 then GlobalColor("Long")
else if trend == -1 then GlobalColor("Short")
else GlobalColor("Neutral")
);
UpperBand3.SetDefaultColor(Color.GRAY);
plot LowerBand = if showATRBands then lowerLine else Double.NaN;
LowerBand.SetLineWeight(1);
LowerBand.AssignValueColor(
if trend == 1 then GlobalColor("Long")
else if trend == -1 then GlobalColor("Short")
else GlobalColor("Neutral")
);
#LowerBand.SetDefaultColor(Color.GRAY);
plot LowerBand2 = if showATRBands then lowerLine2 else Double.NaN;
LowerBand2.SetLineWeight(1);
LowerBand2.AssignValueColor(
if trend == 1 then GlobalColor("Long")
else if trend == -1 then GlobalColor("Short")
else GlobalColor("Neutral")
);
LowerBand2.SetDefaultColor(Color.GRAY);
# Fill between MA and bands — split by trend state for correct cloud color
# Upper cloud (MA to upperLine)
plot UpperLong = if trend == 1 then upperLine else Double.NaN;
plot UpperShort = if trend == -1 then upperLine else Double.NaN;
plot MARefUpper = ma;
MARefUpper.SetDefaultColor(Color.CURRENT);
MARefUpper.SetPaintingStrategy(PaintingStrategy.LINE);
MARefUpper.HideTitle();
MARefUpper.HideBubble();
AddCloud(UpperLong, MARefUpper, GlobalColor("Long"), GlobalColor("Long"));
AddCloud(UpperShort, MARefUpper, GlobalColor("Short"), GlobalColor("Short"));
AddCloud(Lowerband, Lowerband2, Color.dark_GRAY, Color.dark_GRAY);
# Lower cloud (lowerLine to MA)
plot MARefLower = ma;
MARefLower.SetDefaultColor(Color.CURRENT);
MARefLower.SetPaintingStrategy(PaintingStrategy.LINE);
MARefLower.HideTitle();
MARefLower.HideBubble();
AddCloud(upperlong, MARefLower, GlobalColor("Long"), GlobalColor("Long"));
AddCloud(MARefLower, UpperShort, GlobalColor("Short"), GlobalColor("Short"));
AddCloud(Upperband3, Upperband2, Color.dark_GRAY, Color.dark_GRAY);
# ─── SIGNALS ───────────────────────────────────────────────────────────────────
def longTrigger = trend == 1 and trend[1] != 1;
def shortTrigger = trend == -1 and trend[1] != -1;
plot LongArrow = if showSignals and longTrigger then 1 else 0;
LongArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
LongArrow.SetDefaultColor(color.white);
LongArrow.SetLineWeight(4);
plot ShortArrow = if showSignals and shortTrigger then 1 else 0;
ShortArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
ShortArrow.SetDefaultColor(color.white);
ShortArrow.SetLineWeight(4);
# Signal labels
AddChartBubble(showBubble and longSignal, low, "LONG", GlobalColor("Long"), no);
AddChartBubble(showBubble and shortSignal, high, "SHORT", GlobalColor("Short"), yes);
# Dots #
plot BUY = if low < Lowerband2 then low - ATR(60) / 2 else Double.NaN;
BUY.SetPaintingStrategy(PaintingStrategy.POINTS);
BUY.SetDefaultColor(Color.WHITE);
BUY.SetLineWeight(1);
plot SELL = if high > UpperBand3 then high + ATR(60) / 2 else Double.NaN;
SELL.SetPaintingStrategy(PaintingStrategy.POINTS);
SELL.SetDefaultColor(Color.WHITE);
SELL.SetLineWeight(1);
# ─── BAR COLORING ──────────────────────────────────────────────────────────────
AssignPriceColor(
if !colorBars then Color.CURRENT
else if trend == 1 then GlobalColor("Long")
else if trend == -1 then GlobalColor("Short")
else GlobalColor("Neutral")
);
# ─── ALERTS ────────────────────────────────────────────────────────────────────
Alert(alerts and longSignal, "RMA ATR Bands Long Signal", Alert.BAR, Sound.Ding);
Alert(alerts and shortSignal, "RMA ATR Bands Short Signal", Alert.BAR, Sound.Bell);
Here is the LOWER INDICATOR:
Code:
# RMA_ATR_Oscillator
# Lower panel companion to RMA_ATR_Bands
# Created by Chewie 6/9/2026
declare lower;
# ─── INPUTS (match upper study) ────────────────────────────────────────────────
input maSrc = FundamentalType.HIGH;
input maLength = 14;
input atrLength = 13;
input upperMult = 0.4;
input upperMult2 = 1.6;
input upperMult3 = 3.0;
input lowerMult = 1.6;
input lowerMult2 = 3.0;
input showSignals = yes;
input showBubble = no;
input dots = yes;
input alerts = no;
# ─── BASE CALCULATIONS ─────────────────────────────────────────────────────────
def src = Fundamental(maSrc);
def ma = WildersSmoothing(src, maLength);
def atr = Average(TrueRange(high, close, low), atrLength);
# Normalized oscillator: price distance from RMA expressed in ATR units
def osc = (close - ma) / atr;
# ─── TREND (mirrors upper study) ───────────────────────────────────────────────
def isLong = osc > upperMult;
def isShort = osc < -lowerMult;
def trend;
if isLong {
trend = 1;
} else if isShort {
trend = -1;
} else {
trend = trend[1];
}
def longSignal = trend == 1 and trend[1] != 1;
def shortSignal = trend == -1 and trend[1] != -1;
# ─── COLORS ────────────────────────────────────────────────────────────────────
DefineGlobalColor("Long", CreateColor(57, 255, 20));
DefineGlobalColor("Short", CreateColor(138, 50, 255));
DefineGlobalColor("Neutral", Color.GRAY);
# ─── FIXED BAND LINES ──────────────────────────────────────────────────────────
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(Color.GRAY);
ZeroLine.SetLineWeight(2);
ZeroLine.HideTitle();
plot UpBand1 = upperMult;
UpBand1.SetDefaultColor(GlobalColor("Long"));
UpBand1.SetLineWeight(1);
UpBand1.SetStyle(Curve.SHORT_DASH);
UpBand1.HideTitle();
plot UpBand2 = upperMult2;
UpBand2.SetDefaultColor(GlobalColor("Long"));
UpBand2.SetLineWeight(2);
UpBand2.HideTitle();
plot UpBand3 = upperMult3;
UpBand3.SetDefaultColor(GlobalColor("Long"));
UpBand3.SetLineWeight(3);
UpBand3.HideTitle();
plot LoBand1 = -lowerMult;
LoBand1.SetDefaultColor(GlobalColor("Short"));
LoBand1.SetLineWeight(2);
LoBand1.HideTitle();
plot LoBand2 = -lowerMult2;
LoBand2.SetDefaultColor(GlobalColor("Short"));
LoBand2.SetLineWeight(3);
LoBand2.HideTitle();
AddCloud(UpBand3, UpBand2, Color.DARK_GRAY, Color.DARK_GRAY);
AddCloud(LoBand1, LoBand2, Color.DARK_GRAY, Color.DARK_GRAY);
# ─── OSCILLATOR LINE ───────────────────────────────────────────────────────────
plot OscLine = osc;
OscLine.SetLineWeight(2);
OscLine.AssignValueColor(
if trend == 1 then GlobalColor("Long")
else if trend == -1 then GlobalColor("Short")
else GlobalColor("Neutral")
);
# ─── CLOUD: fill between oscillator and zero line ──────────────────────────────
plot OscPos = if osc >= 0 then osc else Double.NaN;
plot OscNeg = if osc < 0 then osc else Double.NaN;
OscPos.SetDefaultColor(Color.CURRENT);
OscPos.HideTitle();
OscPos.HideBubble();
OscNeg.SetDefaultColor(Color.CURRENT);
OscNeg.HideTitle();
OscNeg.HideBubble();
plot ZeroRef = 0;
ZeroRef.SetDefaultColor(Color.CURRENT);
ZeroRef.HideTitle();
ZeroRef.HideBubble();
AddCloud(OscPos, ZeroRef, GlobalColor("Long"), Color.DARK_GRAY);
AddCloud(ZeroRef, OscNeg, GlobalColor("Short"), Color.DARK_GRAY);
# ─── SIGNALS ───────────────────────────────────────────────────────────────────
plot LongArrow = if showSignals and longSignal then -lowerMult - 0.2 else Double.NaN;
LongArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
LongArrow.SetDefaultColor(Color.WHITE);
LongArrow.SetLineWeight(4);
plot ShortArrow = if showSignals and shortSignal then upperMult + 0.2 else Double.NaN;
ShortArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ShortArrow.SetDefaultColor(Color.WHITE);
ShortArrow.SetLineWeight(4);
AddChartBubble(showBubble and longSignal, osc, "L", GlobalColor("Long"), no);
AddChartBubble(showBubble and shortSignal, osc, "S", GlobalColor("Short"), yes);
# ─── DOTS (price outside outer bands) ──────────────────────────────────────────
plot BuyDot = if dots and osc < -lowerMult2 then -lowerMult2 - 0.5 else Double.NaN;
BuyDot.SetPaintingStrategy(PaintingStrategy.POINTS);
BuyDot.SetDefaultColor(Color.WHITE);
BuyDot.SetLineWeight(3);
plot SellDot = if dots and osc > upperMult3 then upperMult3 + 0.5 else Double.NaN;
SellDot.SetPaintingStrategy(PaintingStrategy.POINTS);
SellDot.SetDefaultColor(Color.WHITE);
SellDot.SetLineWeight(3);
# ─── ALERTS ────────────────────────────────────────────────────────────────────
Alert(alerts and longSignal, "RMA ATR Osc Long", Alert.BAR, Sound.Ding);
Alert(alerts and shortSignal, "RMA ATR Osc Short", Alert.BAR, Sound.Bell);
Last edited: