RSI pine script

El espacio del Foro donde compartir indicadores y estrategias creados con el lenguaje de la plataforma TradingView.
Responder
sebaas
Mensajes: 5
Registrado: 01 Ene 2022 16:05

RSI pine script

Mensaje 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
Avatar de Usuario
X-Trader
Administrador
Mensajes: 12781
Registrado: 06 Sep 2004 10:18
Contactar:

Re: RSI pine script

Mensaje 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
"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."
sebaas
Mensajes: 5
Registrado: 01 Ene 2022 16:05

Re: RSI pine script

Mensaje por sebaas »

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
Avatar de Usuario
X-Trader
Administrador
Mensajes: 12781
Registrado: 06 Sep 2004 10:18
Contactar:

Re: RSI pine script

Mensaje 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 ;) :

Código: Seleccionar todo

type=input.double, 
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
"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!


Responder

Volver a “Pine Script”