OPEN-SOURCE SCRIPT
ATR + Moving Average Indicator

//version=5
indicator("ATR + Moving Average Indicator", overlay=true)
// === Inputs ===
atrLength = input.int(14, "ATR Length")
maLength = input.int(50, "Moving Average Length")
maType = input.string("EMA", "Moving Average Type", options=["SMA", "EMA", "WMA"])
// === ATR Calculation ===
atr = ta.atr(atrLength)
// === Moving Average Calculation ===
ma = switch maType
"SMA" => ta.sma(close, maLength)
"EMA" => ta.ema(close, maLength)
"WMA" => ta.wma(close, maLength)
// === Plot Moving Average ===
plot(ma, title="Moving Average", color=color.yellow, linewidth=2)
// === Show ATR on separate panel ===
plot(atr, title="ATR", color=color.red, linewidth=2, display=display.none) // hides ATR from chart
// To see ATR in a separate pane, enable this line instead:
// indicator("ATR + Moving Average Indicator", overlay=false)
indicator("ATR + Moving Average Indicator", overlay=true)
// === Inputs ===
atrLength = input.int(14, "ATR Length")
maLength = input.int(50, "Moving Average Length")
maType = input.string("EMA", "Moving Average Type", options=["SMA", "EMA", "WMA"])
// === ATR Calculation ===
atr = ta.atr(atrLength)
// === Moving Average Calculation ===
ma = switch maType
"SMA" => ta.sma(close, maLength)
"EMA" => ta.ema(close, maLength)
"WMA" => ta.wma(close, maLength)
// === Plot Moving Average ===
plot(ma, title="Moving Average", color=color.yellow, linewidth=2)
// === Show ATR on separate panel ===
plot(atr, title="ATR", color=color.red, linewidth=2, display=display.none) // hides ATR from chart
// To see ATR in a separate pane, enable this line instead:
// indicator("ATR + Moving Average Indicator", overlay=false)
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.