ADX

KenLeShim · study · 31 行 · 点赞 1,978 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=3
study(title="ADX", overlay=false)
 
len = input(14, title="ADX Lenght")
limit = input(20, title="ADX Limit")
diftime = input(true, title="Show Different Timeframe ?")
res = input(title="Different Timeframe :", type=resolution, defval="D")
backcol = input(false, title="Show Background Color Current Timeframe ?")
backcol2 = input(false, title="Show Background Color Different Timeframe ?")
 
up = change(high)
down = -change(low)
trur = rma(tr, len)
plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / trur)
minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / trur)
sum = plus + minus 
 
adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), len)
adx2 = diftime ? security(tickerid, res, 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), len)) : na
 
col = adx >= limit ? green : red
col2 = adx2 >= limit ? green : red
 
plot(adx, style=histogram, linewidth=2, color=col, title="ADX Current Timeframe")
plot(adx2, style=circles, linewidth=2, color=col2, title="ADX Different Timeframe")
hline(limit)
 
test = (backcol and adx >= limit) ? lime : na
test2 = (backcol2 and adx2 >= limit) ? lime : na
bgcolor(test, transp=90)
bgcolor(test2, transp=90)

← 返回列表