Indicator · Pine Script v5 · On the chart

Relarive Strength Index

by CjHare

Relarive Strength Index calculates the RSI oscillator using a configurable source such as close prices, a period length, and an offset value.

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code30
Settings3inputs
LicenceApache-2.0
Last update2 years ago4 Aug 2024

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

30 lines of Pine Script v5 from src/indicator/rsi.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

rsi.pine
// RSI indicator
//
// Input configuration
// - sourceInput: close; the OHLC input for the RSI
// - lengthInput: 14; number of periods for the RSI
// - offsetInput: 0; 
//
// Output:
// - RSI solid line
// - Overbought dotted line
// - Oversold dotted line


//@version=5
indicator(title="Relarive Strength Index", shorttitle="RSI with timeframe", overlay=true, timeframe="D", timeframe_gaps=true)

// Configurable input fields
float   sourceInput = input.source(close, title="Source")
int     lengthInput = input.int(14, minval=1, title="Length")
int     offsetInput = input.int(title="Offset", defval=0, minval=-500, maxval=500)

// RSI is between 0 and 100
float rsi = ta.rsi(sourceInput, lengthInput)

// Plot RSI line
plot(rsi, color=color.blue, title="RSI", offset=offsetInput)

// Plot horizontal lines
hline(80, "Overbought", color=color.gray, linestyle=hline.style_dotted)
hline(20, "Oversold", color=color.gray, linestyle=hline.style_dotted)

Overview

Relarive Strength Index plots the RSI line directly on the price chart along with dotted horizontal lines marking overbought at 80 and oversold at 20. The main settings control the input source, calculation length, and plot offset for alignment. This is an overlay indicator designed for trend and momentum analysis on any chart timeframe.

Details

Published by

CjHare on GitHub

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

pinescript-indicatorspinescript-strategies

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
SourcesourceclosesourceInput
Lengthint14lengthInput
Offsetint0offsetInput
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

947 stars

The Adaptive RSI Moving Average (ARSIMA) is an overlay indicator that dynamically adjusts its smoothing factor based on the Relative Strength Index (RSI). When the RSI moves toward extreme overbought or oversold conditions, the smoothing factor increases to ma

Indicator v4 Moving averagesOscillators & momentum
Updated 12 days ago · GPL-3.0 GitHub repository of Adaptive RSI Moving Average

This overlay indicator screens a pasted list of up to forty symbols and draws a table on the price chart. It classifies bullish or bearish setups from the percent change between the current candle and the candle 250 bars back, then shows RSI with a simple movi

Indicator v5 Oscillators & momentumVolume
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - Ankush Bajaj Momentum Investing Setup

This indicator plots trade entry and exit signals on the price chart by combining Bollinger Bands with optional filter conditions. It calculates standard Bollinger Bands along with RSI, Aroon, and moving average filters. Reversal signals trigger when price bre

Indicator v4 Volatility & bandsOscillators & momentum
Updated 2 months ago · None stated GitHub repository of Bollinger Bands Winner IND [Alorse]
318 stars

This indicator plots three moving averages on the price chart alongside colored fills between the lines to visualize trend structure. Internally, it calculates a Stochastic RSI oscillator to detect oversold reversals. When the Stochastic %K line rises above 10

Indicator v5 Moving averagesOscillators & momentum
Updated 2 months ago · MIT GitHub repository of TVT 3X Scale In Out
285 stars

Mean Reversion Study is an indicator that identifies trade setups combining exponential moving averages, RSI extremes, and engulfing candlestick patterns. It highlights bullish setups when a bullish engulfing candle forms below the EMA while RSI is oversold, a

Indicator v4 Mean reversionCandlestick patterns
Updated 3 years ago · None stated GitHub repository of Mean Reversion Study

More Oscillators & momentum scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers