Change RSI Plot Range - Possible or not?

 

We know that RSI plotting range is between 0 to 100.

Is it possible to change a plotted indicator line so that it will fluctuate in an extended range, say -50 to 100 ?

In simple way I want it to be (stretched) so I can easily draw trend line on the RSI line.

Attached photo is sample of what I mean on is perfect , one that I have is not like it.

I want the the RSI to cross the green and red area without affecting the movement of the indicator. I just want it to be stretching.


//@version=5
indicator(title="Relative Strength Index", shorttitle="RSI", format=format.price, precision=2, timeframe="", timeframe_gaps=true)

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(50, title="MA Length", 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)

rsicolor = rsi > 70 ? color.new(#ff0057, 0) : rsi < 30 ? color.new(#ff0057, 0) : #1056ee

plot(rsi, "RSI", color=rsicolor, linewidth=2, style=plot.style_stepline)
plot(rsiMA, "RSI-based MA", color=color.rgb(120, 206, 255))


OverBought1 = input.int(80, minval=1)
OverBought2 = input.int(90, minval=1)
OverSold1 = input.int(20, minval=1)
OverSold2 = input.int(10, minval=1)


OB1 = hline(OverBought1 , color=color.red, linestyle=hline.style_dashed)
OB2 = hline(OverBought2 , color=color.red, linestyle=hline.style_dashed)
OS1 = hline(OverSold1 , color=color.green, linestyle=hline.style_dashed)
OS2 = hline(OverSold2 , color=color.green, linestyle=hline.style_dashed)

fill(OB1 , OB2, color=color.rgb(255, 82, 82, 80), title="Red Zoon Fill")
fill(OS1 , OS2 , color=color.rgb(76, 175, 79, 80), title="Green Zoon Fill")

Any ideas, please?

Thank you!

Colin

Files:
problem.png  90 kb
perfect.png  90 kb
 
Kalmb: We know that RSI plotting range is between 0 to 100. Is it possible to change a plotted indicator line so that it will fluctuate in an extended range, say -50 to 100 ? In simple way I want it to be (stretched) so I can easily draw trend line on the RSI line. Attached photo is sample of what I mean on is perfect , one that I have is not like it. I want the the RSI to cross the green and red area without affecting the movement of the indicator. I just want it to be stretching. Any ideas, please? Thank you! Colin
[new range] = [original range] * 1.5 - 50
 
Fernando Carreiro #:
[new range] = [original range] * 1.5 - 50

Could you please help me and write the necessary changes from the above code? 

Many thanks Fernando

 
Kalmb #: Could you please help me and write the necessary changes from the above code? Many thanks Fernando

Your code is definitely not MQL and your screenshots don't seem to be of MetaTrader.

This site is dedicated to MetaTrader and the MQL computer language.

I suggest placing your request at a forum dedicated to that software and language you are using. It is beyond the scope of this forum.