You are on page 1of 1

//@version=4

study("ADX cross DM+ DM- Indicator")

adxlen = input(9, title="ADX Smoothing")


dilen = input(14, title="DI Length")
ADX_Entry = input(25, title="ADX Entry")

//ADX
dirmov(len) =>
up = change(high)
down = -change(low)
truerange = rma(tr, len)
plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange)
minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / truerange)
[plus, minus]

adx(dilen, adxlen) =>


[plus, minus] = dirmov(dilen)
sum = plus + minus
adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
[adx, plus, minus]

[sig, up, down] = adx(dilen, adxlen)

plot(ADX_Entry, color=color.white, linewidth=3)


plot(sig, color=color.black, linewidth=4)
plot(up, color=color.green, linewidth=2)
plot(down, color=color.red, linewidth=2)

plot(cross(up,down) ? down : na, color= (down-up > 0 ? color.red : color.lime),


style=plot.style_circles, linewidth=4)
bgcolor(down-up > 0 ? color.red : color.lime, transp=60)

You might also like