Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // © sfeorginal
- // © herocom
- //@version=5
- indicator(title='Mehdi Extended Stochastic', shorttitle='Stoch', precision=0, overlay=false)
- // K D S E
- showema = input(false, title='Show EMA')
- showsma = input(false, title='Show SMA')
- periodK = input.int(14, title='%K Length', minval=1)
- periodD = input.int(3, title='%D Length', minval=2)
- smoothK = input.int(6, title='Smoothing', minval=1)
- showshape = input(true, title='Show Shapes')
- periodE = input.int(13, title='E Length (EMA of K)', minval=1)
- periodS = input.int(21, title='S Length (Slow SMA of K)', minval=1)
- k0 = ta.stoch(close, high, low, periodK)
- k = ta.sma(k0, smoothK)
- d = ta.sma(k, periodD)
- e = ta.ema(k, periodE)
- s = ta.sma(k, periodS)
- //KDSE Plots
- fillk = plot(k, title='%K', color=color.new(color.orange, 0), linewidth=3)
- filld = plot(d, title='%D(Fast SMA of %K)', color=color.new(color.purple, 5), linewidth=3)
- kemacol = e > 80 ? color.new(color.red, 5) : e < 20 ? color.new(color.red, 5) : color.new(color.red, 30)
- ksmacol = s > 80 ? color.new(color.white, 10) : s < 20 ? color.new(color.white, 10) : color.new(color.white, 50)
- plot(showema ? e : na, title='%E(EMA of %K)', color=color.new(kemacol, 50), linewidth=1)
- plot(showsma ? s : na, title='%S(Slow SMA of %K)', color=color.new(ksmacol, 50), linewidth=1)
- //Crosses
- crossup = ta.crossover(k, d)
- crossdown = ta.crossover(d, k)
- crosscolor = crossup ? color.aqua : crossdown ? color.purple : na
- //Conditions
- UP = showshape and crossup and d < 29 and e < 29
- DOWN = showshape and crossdown and d > 71 and e > 71
- UP2 = showshape and crossup and d < 9 and e <= 38.2
- DOWN2 = showshape and crossdown and d > 91 and e >= 61.8
- //Shape Plots
- plotshape(UP ? 0 : na, color=color.new(crosscolor, 50), location=location.absolute, size=size.tiny, style=shape.triangleup, title='Up 1')
- plotshape(DOWN ? 100 : na, color=color.new(crosscolor, 50), location=location.absolute, size=size.tiny, style=shape.triangledown, title='Down 1')
- plotshape(UP2 ? -7 : na, color=color.new(crosscolor, 25), location=location.absolute, size=size.tiny, style=shape.triangleup, title='Up 2')
- plotshape(DOWN2 ? 107 : na, color=color.new(crosscolor, 25), location=location.absolute, size=size.tiny, style=shape.triangledown, title='Down 2')
- //Horizontal Lines
- h1 = hline(90, color=color.new(color.aqua, 50), linewidth=1, linestyle=hline.style_dashed, title='Bull Danger Level')
- h2 = hline(80, color=color.new(color.aqua, 50), linewidth=2, linestyle=hline.style_dashed, title='Bullish Level')
- h2_2 = hline(61.8, color=color.new(color.aqua, 80), linewidth=1, linestyle=hline.style_dashed, title='Fibo Bullish Level')
- h3 = hline(60, color=color.new(color.silver, 75), linewidth=1, linestyle=hline.style_dashed, title='Bull Mid Level')
- h4 = hline(50, color=color.new(color.silver, 90), linewidth=1, linestyle=hline.style_dotted, title='Mid Level')
- h5 = hline(40, color=color.new(color.silver, 75), linewidth=1, linestyle=hline.style_dashed, title='Bear Mid Level')
- h5_5 = hline(38.2, color=color.new(color.purple, 80), linewidth=1, linestyle=hline.style_dashed, title='Fib Bearish Level')
- h6 = hline(20, color=color.new(color.purple, 50), linewidth=2, linestyle=hline.style_dashed, title='Bearish Level')
- h7 = hline(10, color=color.new(color.purple, 50), linewidth=1, linestyle=hline.style_dashed, title='Bear Danger Level')
- //Zones / Histogram
- Hist_Col = k > d ? color.aqua : color.new(color.purple, 50)
- hist = k - d
- plot(hist + 50, title='Histogram', style=plot.style_columns, color=color.new(Hist_Col, 60), histbase=50)
- fill(h1, h2, color=color.new(color.aqua, 95), title='Bull Danger Zone')
- fill(h2, h3, color=color.new(color.aqua, 90), title='Bull Control Zone')
- //fill(h3, h5, color=color.silver, transp=90, title="Neutral Zone")
- fill(h5, h6, color=color.new(color.purple, 90), title='Bear Control Zone')
- fill(h6, h7, color=color.new(color.purple, 95), title='Bear Danger Zone')
Advertisement
Add Comment
Please, Sign In to add comment