Advertisement
Guest User

DMI

a guest
Sep 19th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. study("DMI SUPER SPECIAL TOP SECRET INDICATOR", shorttitle="DMI")
  2. DMILen = input(14, title="DI length")
  3. ADXLen = input(14, title="DI length")
  4. magicValue = input(22.5)
  5.  
  6. dmi(len) =>
  7. up = change(high)
  8. down = -change(low)
  9. truerange = rma(tr, len)
  10. plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange)
  11. minus = fixnan(100 * rma(up < down and down > 0 ? down : 0, len) / truerange)
  12. [plus, minus]
  13.  
  14. adx(DMILen, ADXLen) =>
  15. [plus, minus] = dmi(DMILen)
  16. sum = plus + minus
  17. adxVal = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), ADXLen)
  18. [adxVal, plus, minus]
  19.  
  20. [avg, up, down] = adx(DMILen, ADXLen)
  21.  
  22.  
  23. upPlot = plot(up,color=green,title="+DI")
  24. downPlot = plot(down,color=blue,title="-DI")
  25. plot(avg, color=orange,title="ADX")
  26.  
  27. fillColor = up > down ? green : red
  28. //fill(upPlot, downPlot, color=fillColor, transp=50)
  29.  
  30. horizontal = plot(series=magicValue, color=purple, style=line, transp=25)
  31. tValue = magicValue > up and down > up ? black : green
  32. tValue2 = magicValue > down and down < up ? black : blue
  33. fill(horizontal, upPlot, color=tValue, transp=50)
  34. fill(horizontal, downPlot, color=tValue2, transp=50)
  35.  
  36. barcolor(fillColor)
  37. bgcolor(fillColor)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement