title: How to develop multiple timeframe RSI in pinescript for TradingView
body: <p>I am trying to develop a multiple time-frame RSI using pine-script on trading view but I seem to have an issue with shorter term RSI in a longer term chart view.  </p>
  
  <p>For example, the following code will display 5-min RSI. It will display the RSI appropriately if I have the chart set at 5-min. But when I select a larger time-frame (e.g., 1 hour, etc) the value becomes incorrect. </p>
  
  <pre><code>study("Multi Time Frame RSI", "MTF RSI", overlay=false)
  src = input(title="Source", type=source, defval=close)
  _5min_rsi = security(tickerid, "5", rsi(src, 14))
  plot(_5min_rsi, title="5min_RSI", color=purple, linewidth=1)
  </code></pre>
  
  <p>I believe the problem has to do with series data being operated on. For some reason when I use security with "5" as my resolution, its data gets lost in the higher time-frame charts and it uses the close of a different series for that time. At least that is my hypothesis. I believe I am using the "security" function wrong or possibly providing the wrong input "src" to the RSI function. </p>
  
  <p>I have also tried switching RSI and security to see if I can fetch the 5 min series data and input that into my RSI function but that doesn't work any better. E.g. </p>
  
  <pre><code>_5min_rsi = rsi(security(tickerid, "5", src), 14)
  </code></pre>
  
  <p>Essentially, what I need to see is that no matter what time-frame I am on in trading view I should see 5 min RSI calculated correctly. In the current state, the code will only work in 1 min and 5 min time-frames which is obviously unacceptable.</p>