Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=4
- //©BigThinker
- // Combination of two previous indicators:
- // https://www.tradingview.com/script/2rZDPyaC-Leledc-Exhaustion-Bar/
- // https://www.tradingview.com/script/jB2a9GAV-Leledc-levels-IS/
- study(title='Leledc Exhaustion levels',shorttitle="Leledc Levels",overlay=true)
- //Input
- maj_length= input(30,"Major Exhaustions swing length")
- maj_bars= input(6,"Major Exhaustion bar count")
- min_length= input(5,"Minor Exhaustions swing length")
- min_bars= input(5,"Minor Exhaustion bar count")
- maj=input(true,title="Show Major exhaustion Bar point (Arrows/Full circles)")
- min=input(true,title="Show Minor exhaustion Bar point (empty circles)")
- thicknesSwitch = input(2, title="Line Thickness(Level thickness)")
- //Fun Lele
- Lelec(bars, len) =>
- bindex = int(na)
- bindex := nz(bindex[1], 0)
- sindex = int(na)
- sindex := nz(sindex[1], 0)
- return = 0
- bindex := close > close[4] ? bindex + 1 : bindex
- sindex := close < close[4] ? sindex + 1 : sindex
- if bindex > bars and close < open and high >= highest(high, len)
- bindex := 0
- return := -1
- return
- else
- if sindex > bars and close > open and low <= lowest(low, len)
- sindex := 0
- return := 1
- return
- //Out C
- major = Lelec(maj_bars, maj_length)
- minor = Lelec(min_bars, min_length)
- plotchar(maj ? (major==-1?high:na) : na, char='•',location=location.absolute,color=color.red,size=size.normal)
- plotchar(maj ? (major==1?low:na) : na , char='•',location=location.absolute,color=color.lime,size=size.normal)
- plotchar(min ? (minor==-1?high:na) : na, char='○',location=location.absolute,color=color.red,size=size.normal)
- plotchar(min ? (minor==1?low:na) : na , char='○',location=location.absolute,color=color.lime,size=size.normal)
- Lelex = Lelec(maj_bars, maj_length)
- //Out Bar
- highlel = Lelex == -1 ? high : na
- lowlel = Lelex == 1 ? low : na
- //Out level
- resistance = float(na)
- support = float(na)
- resistance := close < open and Lelex ? high : resistance[1]
- support := close > open and Lelex ? low : support[1]
- //Color
- rescol=color.new(#ff0000, 1)
- highcol = change(resistance) == 0 ? rescol: na
- supcol=color.new(#138484, 1)
- lowcol = change(support) == 0 ? supcol : na
- //Plot Bar
- plotshape(maj ? lowlel : na,title="Up", color=color.new(#00ff00,1), location=location.belowbar, style=shape.triangleup, size=size.normal)
- plotshape(maj ? highlel: na,title="Down", color=color.new(#ff0000, 1), location=location.abovebar, style=shape.triangledown, size=size.normal)
- //Plot level
- plot(maj ? resistance :na, title="Reistance Level", style=plot.style_line, color=highcol, linewidth=thicknesSwitch)
- plot(maj ? support :na, title="Support Level", style=plot.style_line, color=lowcol, linewidth=thicknesSwitch)
- alertcondition(lowlel, "Up")
- alertcondition(highlel, "Down")
Advertisement
Add Comment
Please, Sign In to add comment