Skip to content

Instantly share code, notes, and snippets.

@bongkook
Last active November 11, 2019 03:54
Show Gist options
  • Save bongkook/9960b83b53e72609c2955a5c12c4f4d5 to your computer and use it in GitHub Desktop.
Save bongkook/9960b83b53e72609c2955a5c12c4f4d5 to your computer and use it in GitHub Desktop.
DMIについて
https://kasobu.com/komaashi/
http://xn--fx-3s9cx68e.xyz/report/adx_dmi/
study("Directional Movement", shorttitle="DMI")
adxlen = input(17, title="ADX Smoothing")
dilen = input(17, title="DI Length")
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(sig, color=red, title="ADX")
plot(up, color=blue, title="+DI")
plot(down, color=orange, title="-DI")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment