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!

### What are Moving Averages and How to Use Them in Tuned Script

What Is a Moving Average (MA)? In statistics, a moving average is a calculation used to analyze data points by creating a series of averages of …

### QFL (Quick Fingers Luc’s) Base Cracker Strategy

This article marks the beginning of a new series on our blog. We’ll dig into a trading strategy developed by QuickFingers Luc and apply it …

### 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 …

### Profit From Volatility With Algo Trading on Tuned

Volatility refers to the amount of price change over a given period of time. The greater the amount and velocity of change, the higher …

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

All investing involves risk, including the possible loss of all the money you invest, and past performance does not guarantee future performance. Historical returns expected returns, and probability projections are provided for informational and illustrative purposes, and may not reflect actual future performance.

Tuned is not a broker-dealer, exchange, custodian, wallet provider, or counterparty. Investing is highly speculative and volatile. Tuned is only suitable for investors who fully understand the risk of loss and may experience large drawdowns. Investors should never invest more than they can afford to lose.