Aroon [Loxx]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx

//@version=5
indicator(title="Aroon [Loxx]", shorttitle="AR[Loxx]", timeframe="", timeframe_gaps=true)
     
length = input.int(14, minval=1)


showReg = input.bool(true, "Show Regular Signals", group = "Signal Options")
showCont = input.bool(true, "Show Continuation Signals", group = "Signal Options")

greencolor = color.lime
redcolor =   color.red

upper = 100 * (ta.highestbars(high, length+1) + length)/length
lower = 100 * (ta.lowestbars(low, length+1) + length)/length

QQE2zlongQ = 0
QQE2zlongQ := nz(QQE2zlongQ[1])

QQE2zshortQ = 0
QQE2zshortQ := nz(QQE2zshortQ[1])


long_con = 
     ta.crossover(upper, lower) and
     showReg

short_con = 
     ta.crossunder(upper, lower) and
     showReg

cont_long = 
     upper >= lower and
     QQE2zlongQ ==1  and
     ta.crossover(upper, upper[1]) and
     not long_con and
     showCont
     
cont_short = 
     upper < lower  and
     QQE2zshortQ ==1  and
     ta.crossunder(lower, lower[1]) and
     not short_con and
     showCont
     
qUp = ta.crossover(upper, lower)
qLow = ta.crossunder(upper, lower)

QQE2zlongQ := qUp ? 1 : qLow ? 0 : QQE2zlongQ
QQE2zshortQ := qLow ? 1 : qUp ? 0 : QQE2zshortQ

plot(upper, "Aroon Up", color=greencolor)
plot(lower, "Aroon Down", color=redcolor)

hline(120, color = color.new(color.gray, 100))
hline(-20, color = color.new(color.gray, 100))

plotshape(long_con, title = "Long", color = greencolor, textcolor = greencolor, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(short_con, title = "Short", color = redcolor, textcolor = redcolor, text = "S", style = shape.triangledown, location = location.top, size = size.auto)

plotshape(cont_long, title = "Continuation Long", color = greencolor, textcolor = greencolor, text = "CL", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(cont_short, title = "Continuation Short", color = redcolor, textcolor = redcolor, text = "CS", style = shape.triangledown, location = location.top, size = size.auto)























