RicardoSantos

[RS]Multiple ATR Analysis V1

UPDATE:
• added a mean version of atr using fractional lengths (requested by IvanLabrie):
• uses slow length property for setup.
• added Average Dayly Range (ADR) (requested by IvanLabrie)
• uses fast length property for setup.
• added Average Weekly Range (AWR)
• uses fast length property for setup.
• added Average Monthly Range (AMR)
• uses fast length property for setup.
• added Average Yearly Range (AYR)
• uses fast length property for setup.
開源腳本

本著真正的TradingView精神,該腳本的作者將其開源發布,以便交易者可以理解和驗證它。為作者喝彩吧!您可以免費使用它,但在出版物中重複使用此代碼受網站規則的約束。 您可以收藏它以在圖表上使用。

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。

想在圖表上使用此腳本?
study(title="[RS]Multiple ATR Analysis V1")
fast_length = input(title='Fast ATR Length:', defval=14)
slow_length = input(title='Slow ATR Length:', defval=100)
SHOW_CATR = input(title='Show Cumulative ATR?:', defval=true)
SHOW_MATR = input(title='Show Mean ATR(fractional slow length)?:', defval=true)
SHOW_ADR = input(title='Show Average Dayly Range(fast length)?:', defval=true)
SHOW_WDR = input(title='Show Average Weekly Range(fast length)?:', defval=false)
SHOW_MDR = input(title='Show Average Monthly Range(fast length)?:', defval=false)
SHOW_YDR = input(title='Show Average Yearly Range(fast length)?:', defval=false)

catr = not SHOW_CATR ? na : cum(high-low)/(n+1)
matr = not SHOW_MATR ? na : (atr(round(slow_length*0.05))+atr(round(slow_length*0.25))+atr(round(slow_length*0.5))+atr(slow_length))/4
adr = not SHOW_ADR ? na : security(tickerid, 'D', atr(fast_length))
wdr = not SHOW_WDR ? na : security(tickerid, 'W', atr(fast_length))
mdr = not SHOW_MDR ? na : security(tickerid, 'M', atr(fast_length))
ydr = not SHOW_YDR ? na : security(tickerid, '12M', atr(fast_length))

plot(atr(fast_length), title='Fast ATR', color=red, trackprice=true)
plot(atr(slow_length), title='slow ATR', color=maroon, trackprice=true)
plot(catr, color=blue, title='CATR', trackprice=true)
plot(matr, color=navy, title='MATR', trackprice=true)
plot(adr, color=black, title='ADR', trackprice=true)
plot(wdr, color=gray, title='AWR', trackprice=true)
plot(mdr, color=silver, title='AMR', trackprice=true)
plot(ydr, color=aqua, title='AYR', trackprice=true)
hline(0, color=black)