OPEN-SOURCE SCRIPT

ATR + Moving Average Indicator

58
//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)

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.