jeon
jeon

Reputation: 123

request.security issue in pine script

Hi i want to get RSI value using request.security but when i query previous value which is RSI[1]

it return random value .

if i don't use request.security it return correct RSI value but to get RSI[1] value if use

request.security it return some weird random value.

if anyone help me how to get correct RSI[1] value using request.security?

thanks

rsi  = ta.rsi(close, rsi_length)
rsi1 = ta.rsi(close, 11)[1]
rsiprev = request.security(sym, timeframe.period, rsi1)
rsi_cond = rsi < 50 and rsiprev > 20 and rsiprev < 50 

Upvotes: 0

Views: 216

Answers (1)

Starr Lucky
Starr Lucky

Reputation: 1961

like this:

rsi  = ta.rsi(close, rsi_length)

rsiprev = request.security(sym, timeframe.period, rsi[1])
rsi_cond = rsi < 50 and rsiprev > 20 and rsiprev < 50 

Upvotes: 1

Related Questions