βœ–

Home Forums Pine Script How can I create an RSI indicator in Pine Script?

How can I create an RSI indicator in Pine Script?

  • Author
    Posts
    • 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?

    • 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.

Viewing 1 reply thread
×

Start a Discussion

Get help from the AlgoDelta community.

×

Welcome Back!

Enter your email to sign in or create an account. No passwords needed.

⚠️

Delete This?

Are you sure you want to delete this? This action is permanent and cannot be undone.

Scroll to Top