Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=4
- study(title="Stoch X, an Indicator of Indicators by DGT", shorttitle="StochX by DGT", format=format.price, precision=2, resolution="")
- type = input("Stoch RSI + RSI", "Source + Companion Indicator",
- options=["Stoch Close + PMA",
- "Stoch RSI + RSI",
- "Stoch MFI + MFI",
- "Stoch OBV + VO",
- "Stoch EWO + EWO"])
- smoothK = input(3 , "K", minval=1)
- smoothD = input(3 , "D", minval=1)
- length = input(14, "Length", minval=1)
- dispStoch = input(false,"Display Stochastic Indicator (StochX Highlighted)")
- hideIndi = input(false,"Hide Companion Indicator")
- dummy1 = input(true , "======= Squeeze Indicator Add-On =======")
- dispSqueeze = input(false,"Hide Squeeze Indicator (Close Price)")
- bbkcLength = input(21, " Squeeze Indicator : Length", minval = 1)
- bbMult = input(2, " Squeeze Indicator : Standard Deviation", type=input.float, minval = .25, step = .25, maxval = 3)
- kcMult = input(1.5, " Squeeze Indicator : Volatility MultFactor" , type=input.float, minval = .25, step = .25, maxval = 3)
- // -Calculation ================================================================================= //
- [source, indicator] = if type == "Stoch Close + PMA"
- pma = (close/ema(close,length) - .5 ) * 100
- [close, pma]
- else if type == "Stoch RSI + RSI"
- rsi = rsi(close, length)
- [rsi, rsi]
- else if nz(volume) and type == "Stoch MFI + MFI"
- mfi = mfi(close, length)
- [mfi, mfi]
- else if nz(volume) and type == "Stoch OBV + VO"
- osc = ((ema(volume, 5) - ema(volume, 10))/ema(volume, 10) + .5) * 100
- [obv, osc]
- else if type == "Stoch EWO + EWO"
- ewo = (ema(close, 5)/ema(close, 34) - .5) * 100
- [ewo, ewo]
- k = dispStoch ? sma(stoch(close, high, low, length), smoothK) : na
- kx = sma(stoch(source, source, source, length), smoothK)
- d = sma(kx, smoothD)
- // TTM Squeeze Indicator
- var bool noSqz = na
- if not dispSqueeze
- [_, bbUpper, bbLower] = bb(close, bbkcLength, bbMult)
- [_, kcUpper, kcLower] = kc(close, bbkcLength, kcMult, true)
- noSqz := (bbLower < kcLower) and (bbUpper > kcUpper)
- // -Plot ======================================================================================== //
- // Threshold Lines
- h1 = hline(80, color=#FF6A00, title="Overbought Higher Theshold Level", linestyle=hline.style_dotted)
- h2 = hline(70, color=#FF6A00, title="Overbought Lower Theshold Level" , linestyle=hline.style_dotted)
- fill(h1, h2, color=#FF6A00, title="Overbought Background")
- hline(50, color=color.gray, title="Middle Line Oscillators")
- h3 = hline(30, color=#0094FF, title="Oversold Higher Theshold Level", linestyle=hline.style_dotted)
- h4 = hline(20, color=#0094FF, title="Oversold Lower Theshold Level" , linestyle=hline.style_dotted)
- fill(h3, h4, color=#0094FF, title="Oversold Background")
- // Stoch X
- p1 = plot(kx, "SotchX", color=#0094FF)
- p2 = plot(d, "D", color=#FF6A00)
- fill(p1, p2, color = dispStoch ? kx > d ? #0094FF : #FF6A00 : na, transp = 57)
- plot(hideIndi ? na : indicator, "Companion", color=#FF006E)
- plot(k, "Stoch", color=color.teal)
- // TTM Squeeze Indicator
- plotshape(not dispSqueeze ? true : na, style=shape.diamond, location=location.bottom, color = noSqz ? #0094FF : #FF6A00, title="Squeeze On/Off", transp = 75)
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © 112pc
Advertisement
Add Comment
Please, Sign In to add comment