Support and Resistance Levels with Breaks

https://www.tradingview.com/script/JDFoWQbL-Support-and-Resistance-Levels-with-Breaks/

This script provides basic pivot point Support and Resistance Levels to the user whilst displaying Break signal tags. It also has the ability to let the user display more significant breaks by filtering using the Volume Oscillator. Only more significant breaks of these basic levels are displayed to the user when optimized which avoids noise and messy signals.

Notations

The notation of "B" denotes a break of either a Support or Resistance level with a volume greater than the threshold. The notation of "Bull or Bear Wick" denotes a bullish or bearish candle on the break.

Code

// This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License https://creativecommons.org/licenses/by-sa/4.0/
// © LuxAlgo
//@version = 4
study(title=" Support and Resistance Levels with Breaks",shorttitle = " Support and Resistance Levels with Breaks", overlay = true , max_bars_back=1000)
//
toggleBreaks = input(true, title = "Show Breaks" )
leftBars = input(15, title = "Left Bars ")
rightBars = input(12, title = "Right Bars")
volumeThresh = input(20, title = "Volume Threshold")
//
highUsePivot = fixnan(pivothigh(leftBars, rightBars)[1])
lowUsePivot = fixnan(pivotlow(leftBars, rightBars)[1])
r1 = plot(highUsePivot, color=change(highUsePivot) ? na : #FF0000, linewidth=3, offset=-(rightBars+1), title="Resistance")
s1 = plot(lowUsePivot, color=change(lowUsePivot) ? na : #233dee, linewidth=3, offset=-(rightBars+1), title="Support")
//Volume %
short = ema(volume, 5)
long = ema(volume, 10)
osc = 100 * (short - long) / long
//For breaks with volume
plotshape(toggleBreaks and crossunder(close,lowUsePivot) and not (open - close < high - open) and osc > volumeThresh, title = "Break", text = 'B', style = shape.labeldown, location = location.abovebar, color= color.red,textcolor = color.white, transp = 0, size = size.tiny)
plotshape(toggleBreaks and crossover(close,highUsePivot ) and not(open - low > close - open) and osc > volumeThresh, title = "Break", text = 'B', style = shape.labelup, location = location.belowbar, color= color.green,textcolor = color.white, transp = 0, size = size.tiny)
//For bull / bear wicks
plotshape(toggleBreaks and crossover(close,highUsePivot ) and open - low > close - open , title = "Break", text = 'Bull Wick', style = shape.labelup, location = location.belowbar, color= color.green,textcolor = color.white, transp = 0, size = size.tiny)
plotshape(toggleBreaks and crossunder(close,lowUsePivot) and open - close < high - open , title = "Break", text = 'Bear Wick', style = shape.labeldown, location = location.abovebar, color= color.red,textcolor = color.white, transp = 0, size = size.tiny)
alertcondition(crossunder(close,lowUsePivot) and osc > volumeThresh , title = "Support Broken" , message = "Support Broken")
alertcondition(crossover(close,highUsePivot) and osc > volumeThresh, title = "Resistance Broken" , message = "Resistance Broken")