ADX(DI)过滤开仓信号

2021-11-11 / 0 评论 / 660 阅读
温馨提示:
本文最后更新于2021-11-11,已超过半年没有更新,若内容或图片失效,请留言反馈。

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)

图片alt

2. 代码过滤逻辑

说是ADX,其实只用到了ADX中的DI指标值

DI参数:19
做多:
up > down and up > 27

评论一下?

OωO
取消