vdubus

VDUB_REJECTION_SPIKE_V4 UPDATED / Re vamped & de cluttered

*Updated

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
//@version=2
study("VDUB_REJECTION_SPIKE_V4", overlay=true, shorttitle="VDUB_REJECTION_SPIKE_V4")
//====================channel 1==========================
len = input(55, minval=1, title="EMA LENGTH")
src = input(close, title="Source 1")
out = ema(src, len)
plot(out, title="EMA", color=blue, style=circles, linewidth=1)
last8h = highest(close, 13)
lastl8 = lowest(close, 13)

plot(last8h, color=black, linewidth=1, title="Upper channel 1")
plot(lastl8, color=black, linewidth=1, title="Lower channel 1")

bearish = cross(close,out) == 1 and close[1] > close 
bullish = cross(close,out) == 1 and close[1] < close 

//======================channel 2==================================
len0 = 34
src0 = input(close, title="Source 2")
out0 = sma(src0, len0)
last8h0 = highest(close, 34)
lastl80 = lowest(close, 34)
bearish0 = cross(close,out) == 1 and falling(close, 1)
bullish0 = cross(close,out) == 1 and rising(close, 1)
channel20=input(true, title="Bar Channel On/Off")
ul20=plot(channel20?last8h0:last8h0==nz(last8h0[1])?last8h0:na, color=black, linewidth=2, style=linebr, title="Upper channel 2", offset=0)
ll20=plot(channel20?lastl80:lastl80==nz(lastl80[1])?lastl80:na, color=black, linewidth=2, style=linebr, title="Upper channel 2", offset=0)

// Moddified [RS]Support and Resistance V0
RST = input(title='Support / Resistance length:', type=integer, defval=16)     //
RSTT = valuewhen(high >= highest(high, RST), high, 0)
RSTB = valuewhen(low <= lowest(low, RST), low, 0)
RT2 = plot(RSTT, color=RSTT != RSTT[1] ? na : red, linewidth=2, offset=+0)
RB2 = plot(RSTB, color=RSTB != RSTB[1] ? na : green, linewidth=2, offset=0)

// ZIGZAG -----------------------------------------------//
length = input(4, title="Zigzag Length")
hls = rma(hl2, length)
isRising = hls >= hls[1]

zigzag1 = isRising and not isRising[1] ? lowest(length) :  not isRising and isRising[1] ? highest(length) : na
plot(zigzag1, color=blue, style=line, linewidth=2)
////////////////////////////////////////////////////