xmd79

Mehdi Extended Stochastic

Apr 16th, 2022
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.90 KB | None | 0 0
  1. // © sfeorginal
  2. // © herocom
  3.  
  4. //@version=5
  5.  
  6.  
  7. indicator(title='Mehdi Extended Stochastic', shorttitle='Stoch', precision=0, overlay=false)
  8.  
  9.  
  10.  
  11. // K D S E
  12.  
  13. showema = input(false, title='Show EMA')
  14. showsma = input(false, title='Show SMA')
  15.  
  16. periodK = input.int(14, title='%K Length', minval=1)
  17. periodD = input.int(3, title='%D Length', minval=2)
  18.  
  19. smoothK = input.int(6, title='Smoothing', minval=1)
  20.  
  21. showshape = input(true, title='Show Shapes')
  22.  
  23. periodE = input.int(13, title='E Length (EMA of K)', minval=1)
  24. periodS = input.int(21, title='S Length (Slow SMA of K)', minval=1)
  25.  
  26. k0 = ta.stoch(close, high, low, periodK)
  27. k = ta.sma(k0, smoothK)
  28.  
  29. d = ta.sma(k, periodD)
  30. e = ta.ema(k, periodE)
  31. s = ta.sma(k, periodS)
  32.  
  33.  
  34. //KDSE Plots
  35.  
  36. fillk = plot(k, title='%K', color=color.new(color.orange, 0), linewidth=3)
  37. filld = plot(d, title='%D(Fast SMA of %K)', color=color.new(color.purple, 5), linewidth=3)
  38.  
  39. kemacol = e > 80 ? color.new(color.red, 5) : e < 20 ? color.new(color.red, 5) : color.new(color.red, 30)
  40. ksmacol = s > 80 ? color.new(color.white, 10) : s < 20 ? color.new(color.white, 10) : color.new(color.white, 50)
  41.  
  42. plot(showema ? e : na, title='%E(EMA of %K)', color=color.new(kemacol, 50), linewidth=1)
  43. plot(showsma ? s : na, title='%S(Slow SMA of %K)', color=color.new(ksmacol, 50), linewidth=1)
  44.  
  45.  
  46. //Crosses
  47.  
  48. crossup = ta.crossover(k, d)
  49. crossdown = ta.crossover(d, k)
  50. crosscolor = crossup ? color.aqua : crossdown ? color.purple : na
  51.  
  52.  
  53. //Conditions
  54.  
  55. UP = showshape and crossup and d < 29 and e < 29
  56. DOWN = showshape and crossdown and d > 71 and e > 71
  57.  
  58. UP2 = showshape and crossup and d < 9 and e <= 38.2
  59. DOWN2 = showshape and crossdown and d > 91 and e >= 61.8
  60.  
  61.  
  62. //Shape Plots
  63.  
  64. plotshape(UP ? 0 : na, color=color.new(crosscolor, 50), location=location.absolute, size=size.tiny, style=shape.triangleup, title='Up 1')
  65. plotshape(DOWN ? 100 : na, color=color.new(crosscolor, 50), location=location.absolute, size=size.tiny, style=shape.triangledown, title='Down 1')
  66.  
  67. plotshape(UP2 ? -7 : na, color=color.new(crosscolor, 25), location=location.absolute, size=size.tiny, style=shape.triangleup, title='Up 2')
  68. plotshape(DOWN2 ? 107 : na, color=color.new(crosscolor, 25), location=location.absolute, size=size.tiny, style=shape.triangledown, title='Down 2')
  69.  
  70.  
  71. //Horizontal Lines
  72.  
  73. h1 = hline(90, color=color.new(color.aqua, 50), linewidth=1, linestyle=hline.style_dashed, title='Bull Danger Level')
  74. h2 = hline(80, color=color.new(color.aqua, 50), linewidth=2, linestyle=hline.style_dashed, title='Bullish Level')
  75. h2_2 = hline(61.8, color=color.new(color.aqua, 80), linewidth=1, linestyle=hline.style_dashed, title='Fibo Bullish Level')
  76. h3 = hline(60, color=color.new(color.silver, 75), linewidth=1, linestyle=hline.style_dashed, title='Bull Mid Level')
  77. h4 = hline(50, color=color.new(color.silver, 90), linewidth=1, linestyle=hline.style_dotted, title='Mid Level')
  78. h5 = hline(40, color=color.new(color.silver, 75), linewidth=1, linestyle=hline.style_dashed, title='Bear Mid Level')
  79. h5_5 = hline(38.2, color=color.new(color.purple, 80), linewidth=1, linestyle=hline.style_dashed, title='Fib Bearish Level')
  80. h6 = hline(20, color=color.new(color.purple, 50), linewidth=2, linestyle=hline.style_dashed, title='Bearish Level')
  81. h7 = hline(10, color=color.new(color.purple, 50), linewidth=1, linestyle=hline.style_dashed, title='Bear Danger Level')
  82.  
  83.  
  84. //Zones / Histogram
  85.  
  86. Hist_Col = k > d ? color.aqua : color.new(color.purple, 50)
  87. hist = k - d
  88.  
  89. plot(hist + 50, title='Histogram', style=plot.style_columns, color=color.new(Hist_Col, 60), histbase=50)
  90.  
  91. fill(h1, h2, color=color.new(color.aqua, 95), title='Bull Danger Zone')
  92. fill(h2, h3, color=color.new(color.aqua, 90), title='Bull Control Zone')
  93. //fill(h3, h5, color=color.silver, transp=90, title="Neutral Zone")
  94. fill(h5, h6, color=color.new(color.purple, 90), title='Bear Control Zone')
  95. fill(h6, h7, color=color.new(color.purple, 95), title='Bear Danger Zone')
  96.  
  97.  
Advertisement
Add Comment
Please, Sign In to add comment