How can I create an RSI indicator in Pine Script?

Asked by Radhesh Joshi · SOLVED
1 reply 341 views Jump to solution Reply
Radhesh Joshi Original Post
Strategy Builder

I’m creating my own technical indicators in Pine Script and want to build an RSI indicator from scratch instead of using the built-in RSI.

I want to understand how to calculate the RSI value and plot it properly in a separate indicator pane.

I also want to add the standard 70 and 30 levels so that the overbought and oversold zones are clearly visible.

What is the correct way to create an RSI indicator in Pine Script?

Posted Aug 13
Reply

    1 Reply

    Tech Support AlgoDelta
    Tech Support AlgoDelta Automation Expert ·

    Yes sir, you can definitely create an RSI indicator in Pine Script.

    RSI, or Relative Strength Index, is a momentum indicator that measures the strength of price movements. The commonly used RSI length is 14, with 70 and 30 used as the overbought and oversold reference levels.

    You can create it using:

    //@version=6
    indicator("Custom RSI", overlay=false)
    
    rsiLength = input.int(14, "RSI Length")
    
    rsiValue = ta.rsi(close, rsiLength)
    
    rsiPlot = plot(rsiValue, "RSI")
    overbought = hline(70, "Overbought")
    oversold = hline(30, "Oversold")
    middle = hline(50, "Middle")
    
    fill(overbought, oversold, color=color.new(color.purple, 90))

    -> rsiLength controls the RSI calculation period.

    -> The ta.rsi() function calculates the RSI value using the selected length.

    -> 70 represents the overbought level.

    -> 30 represents the oversold level.

    -> 50 acts as the middle reference level.

    You can change the RSI length directly from the indicator settings without modifying the code.

    So that’s how you can create a basic RSI indicator with overbought and oversold levels in Pine Script.

    Verified Solution
      Markdown supported · ```json for code blocks · paste or drop screenshots

      Be specific and kind. Never share API keys, passwords or personal account details.

      Welcome to the community

      Log in or create your account in under a minute.

      1. 1Mobile
      2. 2E-mail
      3. 3Password
      +91

      Have a password?

      By continuing you agree to the community guidelines. We’ll send a one-time code by SMS.