Advertisement
Guest User

Untitled

a guest
Feb 27th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. //@version=3
  2. study("MACD-DEMA Trendless Indıcator Series-2")
  3.  
  4. maperiod=input(9)
  5. ema=ema(close,maperiod)
  6.  
  7.  
  8. fastmacd = input(12,title='MACD Fast Line Length')
  9. slowmacd = input(48,title='MACD Slow Line Length')
  10. signalmacd = input(9,title='Signal Line Length')
  11.  
  12. macdslowline1 = ema(ema,slowmacd)
  13. macdslowline2 = ema(macdslowline1,slowmacd)
  14. DEMAslow = ((2 * macdslowline1) - macdslowline2 )
  15.  
  16. macdfastline1 = ema(ema,fastmacd)
  17. macdfastline2 = ema(macdfastline1,fastmacd)
  18. DEMAfast = ((2 * macdfastline1) - macdfastline2)
  19.  
  20. MACDLine = (DEMAfast - DEMAslow)
  21.  
  22. SignalLine1 = ema(MACDLine, signalmacd)
  23. SignalLine2 = ema(SignalLine1, signalmacd)
  24. SignalLine = ((2 * SignalLine1) - SignalLine2 )
  25.  
  26.  
  27. MACDSignal = MACDLine-SignalLine
  28.  
  29.  
  30. colorbar= MACDSignal>0?green:red
  31.  
  32. plot(MACDSignal,color=colorbar,style=columns,title='Histogram',histbase=0)
  33. p1 = plot(MACDLine,color=blue,title='MACDLine')
  34. p2=plot(SignalLine,color=red,title="SignalLine")
  35. fill(p1,p2,color=blue)
  36. upper = SignalLine
  37. lower = MACDLine
  38.  
  39. // DIVS code
  40. piv = input(false,"Hide pivots?")
  41. shrt = input(false,"Shorter labels?")
  42. xbars = input(20, "period", integer, minval=1)
  43. hb = abs(highestbars(upper, xbars))
  44. lb = abs(lowestbars(lower, xbars))
  45.  
  46. max = na
  47. max_upper = na
  48. min = na
  49. min_lower = na
  50. pivoth = na
  51. pivotl = na
  52.  
  53.  
  54. max := hb == 0 ? close : na(max[1]) ? close : max[1]
  55. max_upper := hb == 0 ? upper : na(max_upper[1]) ? upper : max_upper[1]
  56. min := lb == 0 ? close : na(min[1]) ? close : min[1]
  57. min_lower := lb == 0 ? lower : na(min_lower[1]) ? lower : min_lower[1]
  58.  
  59.  
  60. if close > max
  61. max := close
  62. if upper > max_upper
  63. max_upper := upper
  64. if close < min_lower
  65. min_lower := lower
  66. if lower < min_lower
  67. min_lower := lower
  68.  
  69. // Finds pivot point with at least 2 right candles with lower value
  70. pivoth := (max_upper == max_upper[2]) and (max_upper[2] != max_upper[3]) ? true : na
  71. pivotl := (min_lower == min_lower[2]) and (min_lower[2] != min_lower[3]) ? true : na
  72.  
  73. plotshape(piv ? na : shrt ? na : pivoth ? max_upper + 2 : na, location=location.absolute, style=shape.labeldown, color=red, size=size.tiny, text="Pivot", textcolor=white, transp=0, offset=0)
  74. plotshape(piv ? na : shrt ? na : pivotl ? min_lower - 2 : na, location=location.absolute, style=shape.labelup, color=blue, size=size.tiny, text="Pivot", textcolor=white, transp=0, offset=0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement