Página 1 de 1
RSI pine script
Publicado: 01 Ene 2022 16:08
por sebaas
Hello , I wanted to ask how do I put a condition (if ....) that RSI has been less than 40 in any of the last 4 candles? (It is a strategy with version 4 of pine script)
Thank you and happy new year
Re: RSI pine script
Publicado: 03 Ene 2022 11:53
por X-Trader
sebaas escribió: 01 Ene 2022 16:08
Hello , I wanted to ask how do I put a condition (if ....) that RSI has been less than 40 in any of the last 4 candles? (It is a strategy with version 4 of pine script)
Thank you and happy new year
Hi there Sebaas and Happy New Year. If you want to create that condition you can write something like this:
Código: Seleccionar todo
rsilevel = input(title="RSI Value Condition", type=input.double, defval=40, minval=0)
length = input(title="Rsi Length", type=input.integer, defval=14, minval=1)
rsi = rsi(close, length)
condition = rsi[1] < rsilevel or rsi[2] < rsilevel or rsi[3] < rsilevel or rsi[4] < rsilevel
if condition
// do something here...
I think it's self-explanatory, but if it's not clear just let me know.
Best regards,
X-Trader
Re: RSI pine script
Publicado: 03 Ene 2022 14:47
por sebaas
Hi thanks for your reply
I used what you said me but it give me error
Re: RSI pine script
Publicado: 04 Ene 2022 17:06
por X-Trader
sebaas escribió: 03 Ene 2022 14:47
Hi thanks for your reply
I used what you said me but it give me error
Opera Instantánea_2022-01-03_144625_es.tradingview.com.png
Ok, I see, there are a couple of errors there. Just remove in line 16 and it will be fixed

:
Also use parenthesis to enclose the RSI conditions like this:
Código: Seleccionar todo
and (rsi[1] < rsilevel or rsi[2] < rsilevel or rsi[3] < rsilevel or rsi[4] < rsilevel)
Regards,
X-Trader