Advertisement
Muinnhuginn

MultiTrend

Oct 20th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. //@version=4
  2. study(" MultiTrendmeter", overlay=false)
  3. //___________________________________________________________________________________________________________
  4. ///DMI INDICATOR///
  5. adxlen = (14)
  6. dilen = (14)
  7. dirmov(len) =>
  8. up = change(high)
  9. down = -change(low)
  10. truerange = rma(tr, len)
  11. plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange)
  12. minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / truerange)
  13. [plus, minus]
  14.  
  15. adx(dilen, adxlen) =>
  16. [plus, minus] = dirmov(dilen)
  17. sum = plus + minus
  18. adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
  19. [adx, plus, minus]
  20.  
  21. [sig, up, down] = adx(dilen, adxlen)
  22.  
  23. plus1 = up > down
  24. minus1 = up < down
  25. adx1 = sig > 20
  26. adx2 = sig > 50
  27.  
  28.  
  29. //_______________________________________________________________________________________________________________
  30. ///VI INDICATOR///
  31. period_ = (14)
  32.  
  33. VMP = sum( abs( high - low[1]), period_ )
  34. VMM = sum( abs( low - high[1]), period_ )
  35. STR = sum( atr(1), period_ )
  36. VIP = VMP / STR
  37. VIM = VMM / STR
  38.  
  39.  
  40. //_______________________________________________________________________________________________________________
  41. ///OBV+SMMA///
  42. src=close
  43. obv = cum(sign(change(src)) * volume)
  44. len = (100)
  45. //src1 = input(obv, title="Source")
  46. smma = 0.0
  47. smma := na(smma[1]) ? sma(obv, len) : (smma[1] * (len - 1) + obv) / len
  48. //plot(smma, color=color.red)
  49. //plot(obv)
  50.  
  51.  
  52. //__________________________________________________________________________________________________________________
  53. ///SIGNALS///
  54. signal1 = up > down ? color.lime : na
  55. signal2 = up < down ? color.orange : na
  56. signal3 = VIP > VIM ? color.green : VIP < VIM ? color.red :na
  57. signal4 = obv > smma ? color.green : obv < smma ? color.red :na
  58. signal5 = plus1 and adx1 ? color.teal : na
  59. signal6 = plus1 and adx2 ? color.green : na
  60. signal7 = minus1 and adx1 ? color.red : na
  61. signal8 = minus1 and adx2 ? color.maroon : na
  62.  
  63. ///PLOTS///
  64. //______________________________________________________________________________________________________________________
  65. plot( 5, color=signal7, style=plot.style_columns, title="1st line", linewidth=2, histbase=4)
  66. plot( 5, color=signal8, style=plot.style_columns, title="1st line", linewidth=2, histbase=4)
  67. plot( 5, color=signal5, style=plot.style_columns, title="1st line", linewidth=2, histbase=4)
  68. plot( 5, color=signal6, style=plot.style_columns, title="1st line", linewidth=2, histbase=4)
  69. plot( 5, color=signal1, style=plot.style_columns, title="1st line", linewidth=2, histbase=4)
  70. plot( 5, color=signal2, style=plot.style_columns, title="1st line", linewidth=2, histbase=4)
  71. plot( 3, color=signal3, style=plot.style_columns, title="2nd line", linewidth=2, histbase=2)
  72. plot( 1, color=signal4, style=plot.style_columns, title="3rd line", linewidth=2, histbase=0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement