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
RSI pine script
Re: RSI pine script
Hi there Sebaas and Happy New Year. If you want to create that condition you can write something like this: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
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...
Best regards,
X-Trader
"Los sistemas de trading pueden funcionar en ciertas condiciones de mercado todo el tiempo, en todas las condiciones de mercado en algún momento del tiempo, pero nunca en todas las condiciones de mercado todo el tiempo."
Re: RSI pine script
Hi thanks for your reply
I used what you said me but it give me error
I used what you said me but it give me error
Re: RSI pine script
Ok, I see, there are a couple of errors there. Just remove in line 16 and it will be fixedsebaas 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

Código: Seleccionar todo
type=input.double,
Código: Seleccionar todo
and (rsi[1] < rsilevel or rsi[2] < rsilevel or rsi[3] < rsilevel or rsi[4] < rsilevel)
X-Trader
"Los sistemas de trading pueden funcionar en ciertas condiciones de mercado todo el tiempo, en todas las condiciones de mercado en algún momento del tiempo, pero nunca en todas las condiciones de mercado todo el tiempo."
Si te ha gustado este hilo del Foro, ¡compártelo en redes!