Strategy Creation

# What is RSI and How to Use It in Tuned Script

## What Is the Relative Strength Index (RSI)?

The relative strength index (RSI) is a momentum indicator used in technical analysis that measures the magnitude of recent price changes to evaluate overbought or oversold conditions in the price of a stock or other asset. The RSI is displayed as an oscillator (a line graph that moves between two extremes) and can have a reading of 0 to 100.

## Key points about the RSI

1. The RSI is a very popular momentum oscillator
2. The RSI provides bullish and bearish momentum signals
3. Usually considered overbought when the RSI is above 70.0 and oversold when below 30.0 (default settings)

Below you will find a short example of using the RSI in your script.

```//Inputs
// Create the input variable for the Length using an intInput
rsiLen = intInput("RSI Length", 14)

// Create the input variable for the overbought/oversold using a numInput
upper = numInput("Overbought Level", 70.0)
lower = numInput("Oversold Level", 30.0)

//indicator
// Define the RSI using the candle CLOSE and the rsiLen Input
RSI = rsi(close, rsiLen)

//Plot
// Plot the RSI and the upper and lower threshold
plot(RSI, "RSI", "#E45CFF", 2, PlotStyle.LINE, 0, false)
plot(seriesOf(upper), "RSI upper", "#ffffff", 1, PlotStyle.LINE, 0, false)
plot(seriesOf(lower), "RSI upper", "#ffffff", 1, PlotStyle.LINE, 0, false)

//Signal Push
out(NEVER_ORDER)```

The above image is how the plot should look on the chart. The pink line is the RSI line, and the 2 horizontal lines are the overbought and oversold areas.

## How to use the RSI to generate buy and sell signals?

For the example I will use the default settings: Length = 14, overbought = 70.0, oversold = 30.0

The most commonly used method for the RSI, is to buy when the RSI crosses up through the oversold threshold, and to sell when the RSI crosses down through the overbought threshold.

This generally indicates a strong momentum change.

```//Inputs
// Create the input variable for the Length using an intInput
rsiLen = intInput("RSI Length", 14)

// Create the input variable for the overbought/oversold using a numInput
upper = numInput("Overbought Level", 70.0)
lower = numInput("Oversold Level", 30.0)

//indicator
// Define the RSI using the candle CLOSE and the rsiLen Input
RSI = rsi(close, rsiLen)

//Plot
// Plot the RSI and the upper and lower threshold
plot(RSI, "RSI", "#E45CFF", 2, PlotStyle.LINE, 0, false)
plot(seriesOf(upper), "RSI upper", "#ffffff", 1, PlotStyle.LINE, 0, false)
plot(seriesOf(lower), "RSI upper", "#ffffff", 1, PlotStyle.LINE, 0, false)

//Entry and Exit Conditions
// Define the Entry condition of RSI crossing over the Lower Threshold

// Define the Exit condition of RSI crossing under the upper Threshold
sell = crossunder(RSI, seriesOf(upper))

//Signal Push
// Here you will output your Entry and Exit signals

Below is a screenshot of how your chart should look:

So now you have learnt what the RSI is, how to use it and how to put it in a script and generate signals from it.

Have fun scripting!

### Trade sideways markets with simple Grid Bots on Tuned

Have you ever seen a chart and wished you could trade all its ups and downs? The profit potential may be tempting but watching candles …

If you’re looking for massive profits in the market, you will have to build a capable strategy. Crypto markets are inherently volatile, which is both …

### What is the Momentum Indicator and how to use it on Tuned?

In this article, we’ll be talking about the Momentum indicator.We’ll be exploring what it does, its common uses and how it can be applied to …

### Tags:

Disclaimer: The opinions expressed here are for general informational purposes only and are not intended to provide specific advice or recommendations for any specific security or investment product. You should never invest money that you cannot afford to lose. Before trading using complex financial products, please ensure to understand the risks involved. Past performance is no guarantee of future results.