Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © finally nitin
- //@version=4
- study(title="Directional Movement Index", shorttitle="ADX", format=format.price, precision=4, resolution="")
- lensig = input(8, title="ADX", minval=1, maxval=50)
- len = input(13, title="DMI length", minval=1, maxval=50)
- th = input(25, title="threshold")
- hline(th, title="Zero", color=color.black, linestyle=hline.style_dotted)
- up = change(high)
- down = -change(low)
- plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
- minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
- trur = rma(tr, len)
- plus = fixnan(100 * rma(plusDM, len) / trur)
- minus = fixnan(100 * rma(minusDM, len) / trur)
- sum = plus + minus
- adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)
- plot(adx, color=#363A45, title="ADX")
- plot(plus, color=#00897B, title="+DI")
- plot(minus, color=#FF5252, title="-DI")
Advertisement
Add Comment
Please, Sign In to add comment