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.
study("[RS]Fractal Levels V1", shorttitle="[RS]FL.V1", overlay=true) hidefractals = input(false) hidelevels = input(false) hideaverage = input(false) topfractal = high < high and high < high and high > high and high > high botfractal = low > low and low > low and low < low and low < low plotchar(hidefractals ? na : topfractal, text="Fractal", location=location.abovebar, offset=-2) plotchar(hidefractals ? na : botfractal, text="Fractal", location=location.belowbar, offset=-2) topfractals = topfractal ? high : topfractals botfractals = botfractal ? low : botfractals topfcolor = topfractals != topfractals ? na : black botfcolor = botfractals != botfractals ? na : black plot(hidelevels ? na : topfractals, color=topfcolor) plot(hidelevels ? na : botfractals, color=botfcolor) fractalma = avg(topfractals, botfractals) plot(hideaverage ? na : fractalma, color=blue, linewidth=2)