0

I am new in pine script and just tring to print the value of RSI of two different timeframes eg "D" (Daily) and "60" (Hourly) using the following code but whenever I change the timeframe from the chart tollber the vales changes !!

daily_close = request.security(syminfo.tickerid, "D", close)
hourly_close = request.security(syminfo.tickerid, "60", close)
rsiD = ta.rsi(daily_close, 14)
rsiH = ta.rsi(hourly_close, 14)
var myTable = table.new(position.bottom_right, 2, 5)
if barstate.islast
 table.cell(myTable, 0, 0, "RSI Daily", text_color = color.white)
 table.cell(myTable, 1, 0, str.tostring(rsiD[0], "#.##"), text_color = color.white)
 table.cell(myTable, 0, 1, "RSI Hourly", text_color = color.white)
 table.cell(myTable, 1, 1, str.tostring(rsiH[0], "#.##"), text_color = color.white)
DarkBee
14.4k9 gold badges86 silver badges135 bronze badges
asked Oct 28, 2025 at 22:10
5
  • What timeframes are you testing this on? Commented Nov 3, 2025 at 21:12
  • Daily and hourly RSI values changes when I change the timeframe to 30Min or 15 Min, Or 5 Min, all the values are different in all the different timeframes Commented Nov 5, 2025 at 15:27
  • Is this a strategy or an indicator? Commented Nov 5, 2025 at 18:58
  • Just a Indicator Printing the daily and hourly RSI values on 5min or 15min Chart Commented Nov 5, 2025 at 19:23
  • Got it ! Thank you ! Commented Nov 6, 2025 at 4:42

1 Answer 1

1

You are getting the close price from the security() and using that in ta.rsi(). However, this will not work as you think it will.

Your daily_close will have the daily close price until there is a new day. This means it will have the same value over multiple bars on the lower timeframe you are testing this on. When you pass this variable to ta.rsi() with a length of 14, calculations will be based on daily_close's value on the lower timeframe (many of them will have the same value as explained just before). And NOT the last 14 daily close prices.

You can actually call functions in security().

rsiD = request.security(syminfo.tickerid, "D", ta.rsi(close, 14))
rsiH = request.security(syminfo.tickerid, "60", ta.rsi(close, 14))
var myTable = table.new(position.bottom_right, 2, 5)
if barstate.islast
 table.cell(myTable, 0, 0, "RSI Daily", text_color = color.white)
 table.cell(myTable, 1, 0, str.tostring(rsiD[0], "#.##"), text_color = color.white)
 table.cell(myTable, 0, 1, "RSI Hourly", text_color = color.white)
 table.cell(myTable, 1, 1, str.tostring(rsiH[0], "#.##"), text_color = color.white)

This will always use the last 14 daily and 1h close prices.

answered Nov 5, 2025 at 20:20
Sign up to request clarification or add additional context in comments.

1 Comment

Got it ! Thank you for the explanation !

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.