ADX(DI)过滤开仓信号
温馨提示:本文最后更新于2021年11月11日 22:28,若内容或图片失效,请在下方留言或联系博主。
1. ADX指标可视化
//@version=5
indicator("Average Directional Index", shorttitle="ADX", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
adxlen = input(14, title="ADX Smoothing")
dilen = input(14, title="DI Length")
dirmov(len) =>
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
truerange = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(plusDM, len) / truerange)
minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
[plus, minus]
adx(dilen, adxlen) =>
[plus, minus] = dirmov(dilen)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
[adx, plus, minus]
[sig, up, down] = adx(dilen, adxlen)
plot(sig, color=color.red, title="ADX")
plot(up, color=color.blue, title="up")
plot(down, color=color.green, title="up")
hline(27)
2. 代码过滤逻辑
说是ADX,其实只用到了ADX中的DI指标值
DI参数:19
做多:
up > down and up > 27