'Adding a stop loss to the RSI value

I'm using this simple RSI indicator on trading view:

ma(source, length, type) =>
    switch type
        "SMA" => ta.sma(source, length)
        "Bollinger Bands" => ta.sma(source, length)
        "EMA" => ta.ema(source, length)
        "SMMA (RMA)" => ta.rma(source, length)
        "WMA" => ta.wma(source, length)
        "VWMA" => ta.vwma(source, length)

rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
rsiSourceInput = input.source(close, "Source", group="RSI Settings")
maTypeInput = input.string("SMA", title="MA Type", options=["SMA", "Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="MA Settings")
maLengthInput = input.int(14, title="MA Length", group="MA Settings")
bbMultInput = input.float(2.0, minval=0.001, maxval=50, title="BB StdDev", group="MA Settings")

up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
rsiMA = ma(rsi, maLengthInput, maTypeInput)
isBB = maTypeInput == "Bollinger Bands"

rsiUpperBand = hline(70, "RSI Upper Band", color=#787B86)
rsiLowerBand = hline(30, "RSI Lower Band", color=#787B86)
RSIOpen = ta.crossover(rsi, rsiMA)
plotshape(RSIOpen, title="TEST", text="RSO", location=location.belowbar, style=shape.square, size=size.auto, color=color.purple, textcolor=color.purple, transp=0)

Which creates a shape every time the rsi band cross over rsiMA. Is it possible to add another value so it shows whenever the close price is 1% lower than the RSIOpen value so we can create some kind of a stop loss to RSIOpen?

Thank you.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source