//@version=4 study(title="Pivot Points High Low (HH/HL/LH/LL) [Anan] ", shorttitle="Pivots HL [Anan]", overlay=true) // - INPUTS ShowPivots = input(true, title="Show Pivot Points") ShowHHLL = input(true, title="Show HH,LL,LH,HL markers on Pivots Points") left = input(5, minval=1, title="Pivot Length Left Hand Side") right = input(5, minval=1, title="Pivot Length Right Hand Side") ShowSRLevels = input(true, title="Show S/R Level Extensions") maxLvlLen = input(0, minval=0, title="Maximum S/R Level Extension Length (0 = Max)") ShowChannel = input(false, title="Show Levels as a Fractal Chaos Channel") // ShowFB = input(true, title="Show Fractal Break Alert Arrows") // Determine pivots pvtLenL = left pvtLenR = right // Get High and Low Pivot Points pvthi_ = pivothigh(high, pvtLenL, pvtLenR) pvtlo_ = pivotlow(low, pvtLenL, pvtLenR) // Force Pivot completion before plotting. pvthi = pvthi_ pvtlo = pvtlo_ // ||-----------------------------------------------------------------------------------------------------|| // ||--- Higher Highs, Lower Highs, Higher Lows, Lower Lows -------------------------------------------|| valuewhen_1 = valuewhen(pvthi, high[pvtLenR], 1) valuewhen_2 = valuewhen(pvthi, high[pvtLenR], 0) higherhigh = na(pvthi) ? na : valuewhen_1 < valuewhen_2 ? pvthi : na valuewhen_3 = valuewhen(pvthi, high[pvtLenR], 1) valuewhen_4 = valuewhen(pvthi, high[pvtLenR], 0) lowerhigh = na(pvthi) ? na : valuewhen_3 > valuewhen_4 ? pvthi : na valuewhen_5 = valuewhen(pvtlo, low[pvtLenR], 1) valuewhen_6 = valuewhen(pvtlo, low[pvtLenR ], 0) higherlow = na(pvtlo) ? na : valuewhen_5 < valuewhen_6 ? pvtlo : na valuewhen_7 = valuewhen(pvtlo, low[pvtLenR], 1) valuewhen_8 = valuewhen(pvtlo, low[pvtLenR ], 0) lowerlow = na(pvtlo) ? na : valuewhen_7 > valuewhen_8 ? pvtlo : na // If selected Display the HH/LL above/below candle. plotshape(ShowHHLL ? higherhigh : na, title='HH', style=shape.triangledown, location=location.abovebar, color=color.new(color.green,50), text="HH", offset=-pvtLenR) plotshape(ShowHHLL ? higherlow : na, title='HL', style=shape.triangleup, location=location.belowbar, color=color.new(color.green,50), text="HL", offset=-pvtLenR) plotshape(ShowHHLL ? lowerhigh : na, title='LH', style=shape.triangledown, location=location.abovebar, color=color.new(color.red,50), text="LH", offset=-pvtLenR) plotshape(ShowHHLL ? lowerlow : na, title='LL', style=shape.triangleup, location=location.belowbar, color=color.new(color.red,50), text="LL", offset=-pvtLenR) plot(ShowPivots and not ShowHHLL ? pvthi : na, title='High Pivot', style=plot.style_circles, join=false, color=color.green, offset=-pvtLenR, linewidth=3) plot(ShowPivots and not ShowHHLL ? pvtlo : na, title='Low Pivot', style=plot.style_circles, join=false, color=color.red, offset=-pvtLenR, linewidth=3) //Count How many candles for current Pivot Level, If new reset. counthi = 0 countlo = 0 counthi := na(pvthi) ? nz(counthi[1]) + 1 : 0 countlo := na(pvtlo) ? nz(countlo[1]) + 1 : 0 pvthis = 0.0 pvtlos = 0.0 pvthis := na(pvthi) ? pvthis[1] : high[pvtLenR] pvtlos := na(pvtlo) ? pvtlos[1] : low[pvtLenR] hipc = pvthis != pvthis[1] ? na : color.new(color.red,50) lopc = pvtlos != pvtlos[1] ? na : color.new(color.green,50) // Show Levels if Selected plot(ShowSRLevels and not ShowChannel and (maxLvlLen == 0 or counthi < maxLvlLen) ? pvthis : na, color=hipc, linewidth=1, offset=-pvtLenR , title="Top Levels",style=plot.style_circles) plot(ShowSRLevels and not ShowChannel and (maxLvlLen == 0 or countlo < maxLvlLen) ? pvtlos : na, color=lopc, linewidth=1, offset=-pvtLenR , title="Bottom Levels",style=plot.style_circles) // Show Levels as a Fractal Chaos Channel plot(ShowSRLevels and ShowChannel ? pvthis : na, color=color.green, linewidth=1, style=plot.style_stepline, offset=0, title="Top Chaos Channel", trackprice=false) plot(ShowSRLevels and ShowChannel ? pvtlos : na, color=color.red, linewidth=1, style=plot.style_stepline, offset=0, title="Bottom Chaos Channel", trackprice=false) // // Add Optional Fractal Break Alerts buy = false sell = false buy := close>pvthis and open<=pvthis sell := close=pvtlos // // plotshape(ShowFB and buy?1:na, title="BUY Arrow", color=color.green, style=shape.labelup,location =location.belowbar) plotshape(ShowFB and sell?-1:na, title="SELL Arrow", color=color.red, style=shape.labeldown,location =location.abovebar) // Alerts// alertcondition(buy or sell,title="Fractal Break Arrow",message="Alert") alertcondition(buy,title="Fractal Break Long",message="Long") alertcondition(sell,title="Fractal Break Short",message="Short")