50% Strat Retracement
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TraderCreatorPro

//@version=5
indicator("50% Retracement", "%", true)
import ZenAndTheArtOfTrading/ZenLibrary/2 as zen

//Input Groups

//User Imputs
percentage = input.float(50, "Percentage retracement")
arrowdown = input.bool(true, "Arrows Down")
arrowup = input.bool(true, "Arrows Up")
rline = input.bool(true, "A line at the Retracement level. (If you want the label to show on the side you will need to turn that on in your chart settings)")

alerts = input.bool(true, "Alerts you if there is a retracement happening")

//line calculation
twoupred = high > high[1] and open > close
twodowngreen = low < low[1] and open< close
Difference = high[1] - low[1]
multiplier = percentage/100
Calculation = Difference * multiplier + low[1]

fiftydown = twoupred and close < Calculation
fiftyup = twodowngreen and close > Calculation

//Add Arrow

plotshape(arrowdown? fiftydown:na , text = "% Rev down", style = shape.arrowdown, size = size.huge, color = color.red)
plotshape(arrowup? fiftyup:na , text = "% Rev Up", style = shape.arrowup, size = size.huge, color = color.green, location = location.belowbar)
plot (rline? Calculation:na, style = plot.style_linebr)


//Alerts
alertcondition (fiftydown and alerts, "Up {{ticker}}, {{close}}")

alertcondition (fiftyup and alerts, "down {{ticker}}, {{close}}")
