xmd79

fft2

May 14th, 2021
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. //@version=4
  2. study(title="Stoch X, an Indicator of Indicators by DGT", shorttitle="StochX by DGT", format=format.price, precision=2, resolution="")
  3.  
  4. type = input("Stoch RSI + RSI", "Source + Companion Indicator",
  5. options=["Stoch Close + PMA",
  6. "Stoch RSI + RSI",
  7. "Stoch MFI + MFI",
  8. "Stoch OBV + VO",
  9. "Stoch EWO + EWO"])
  10.  
  11. smoothK = input(3 , "K", minval=1)
  12. smoothD = input(3 , "D", minval=1)
  13. length = input(14, "Length", minval=1)
  14.  
  15. dispStoch = input(false,"Display Stochastic Indicator (StochX Highlighted)")
  16. hideIndi = input(false,"Hide Companion Indicator")
  17.  
  18.  
  19. dummy1 = input(true , "======= Squeeze Indicator Add-On =======")
  20. dispSqueeze = input(false,"Hide Squeeze Indicator (Close Price)")
  21. bbkcLength = input(21, "  Squeeze Indicator : Length", minval = 1)
  22. bbMult = input(2, "  Squeeze Indicator : Standard Deviation", type=input.float, minval = .25, step = .25, maxval = 3)
  23. kcMult = input(1.5, "  Squeeze Indicator : Volatility MultFactor" , type=input.float, minval = .25, step = .25, maxval = 3)
  24.  
  25. // -Calculation ================================================================================= //
  26.  
  27. [source, indicator] = if type == "Stoch Close + PMA"
  28. pma = (close/ema(close,length) - .5 ) * 100
  29. [close, pma]
  30. else if type == "Stoch RSI + RSI"
  31. rsi = rsi(close, length)
  32. [rsi, rsi]
  33. else if nz(volume) and type == "Stoch MFI + MFI"
  34. mfi = mfi(close, length)
  35. [mfi, mfi]
  36. else if nz(volume) and type == "Stoch OBV + VO"
  37. osc = ((ema(volume, 5) - ema(volume, 10))/ema(volume, 10) + .5) * 100
  38. [obv, osc]
  39. else if type == "Stoch EWO + EWO"
  40. ewo = (ema(close, 5)/ema(close, 34) - .5) * 100
  41. [ewo, ewo]
  42.  
  43. k = dispStoch ? sma(stoch(close, high, low, length), smoothK) : na
  44. kx = sma(stoch(source, source, source, length), smoothK)
  45. d = sma(kx, smoothD)
  46.  
  47. // TTM Squeeze Indicator
  48. var bool noSqz = na
  49. if not dispSqueeze
  50. [_, bbUpper, bbLower] = bb(close, bbkcLength, bbMult)
  51. [_, kcUpper, kcLower] = kc(close, bbkcLength, kcMult, true)
  52.  
  53. noSqz := (bbLower < kcLower) and (bbUpper > kcUpper)
  54.  
  55. // -Plot ======================================================================================== //
  56.  
  57. // Threshold Lines
  58. h1 = hline(80, color=#FF6A00, title="Overbought Higher Theshold Level", linestyle=hline.style_dotted)
  59. h2 = hline(70, color=#FF6A00, title="Overbought Lower Theshold Level" , linestyle=hline.style_dotted)
  60. fill(h1, h2, color=#FF6A00, title="Overbought Background")
  61.  
  62. hline(50, color=color.gray, title="Middle Line Oscillators")
  63.  
  64. h3 = hline(30, color=#0094FF, title="Oversold Higher Theshold Level", linestyle=hline.style_dotted)
  65. h4 = hline(20, color=#0094FF, title="Oversold Lower Theshold Level" , linestyle=hline.style_dotted)
  66. fill(h3, h4, color=#0094FF, title="Oversold Background")
  67.  
  68. // Stoch X
  69. p1 = plot(kx, "SotchX", color=#0094FF)
  70. p2 = plot(d, "D", color=#FF6A00)
  71. fill(p1, p2, color = dispStoch ? kx > d ? #0094FF : #FF6A00 : na, transp = 57)
  72. plot(hideIndi ? na : indicator, "Companion", color=#FF006E)
  73. plot(k, "Stoch", color=color.teal)
  74.  
  75. // TTM Squeeze Indicator
  76. plotshape(not dispSqueeze ? true : na, style=shape.diamond, location=location.bottom, color = noSqz ? #0094FF : #FF6A00, title="Squeeze On/Off", transp = 75)
  77.  
  78. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  79. // © 112pc
  80.  
  81.  
Advertisement
Add Comment
Please, Sign In to add comment