# RSI: relative strength index

> How RSI measures the balance of recent gains and losses, and why overbought does not mean about to fall.

Source: https://quantraider.com/learn/indicators/rsi

Course: Technical indicators (lesson 2 of 6) · Level: Intermediate · 5 min

The relative strength index (RSI) compresses recent price changes into a single number between 0 and 100. You will see how it is calculated with Wilder smoothing, how to work out a value by hand, and why a high reading is not a sell signal on its own.

## What RSI measures

**RSI** compares the size of recent up-moves with the size of recent down-moves. Each candle, the change in close from the previous candle is split into a gain (if positive) or a loss (if negative, stored as a positive number). The indicator then looks at the average gain and the average loss over N candles.

If gains dominate, RSI is high. If losses dominate, it is low. If both are equal, RSI is 50. A period of 14 is a common example, but it is only a convention.

## The calculation with Wilder smoothing

RSI exists in several variants. This lesson uses **Wilder smoothing**, the original method, which is also what the QuantRaider `RSI` node states it uses. Instead of a plain average, the average gain and average loss are updated each candle with a running rule, which is similar to an EMA with α = 1 / N.

```
Average gain now = (Average gain previous × (N − 1) + Gain now) / N
Average loss now = (Average loss previous × (N − 1) + Loss now) / N
RS = Average gain / Average loss
RSI = 100 − 100 / (1 + RS)
```

Gain now and Loss now are the positive up-move or down-move of the latest candle; one of them is zero.

**Worked example: One RSI value from average gain and average loss**

1. Take N = 14 with an average gain of 0.60 and an average loss of 0.40 (in price points).
2. RS = 0.60 / 0.40 = 1.5, so RSI = 100 − 100 / (1 + 1.5) = 100 − 40 = 60.
3. The next candle closes up by 1.00, so the gain is 1.00 and the loss is 0.
4. New average gain = (0.60 × 13 + 1.00) / 14 = 8.80 / 14 = 0.6286. New average loss = (0.40 × 13 + 0) / 14 = 5.20 / 14 = 0.3714.
5. RS = 8.80 / 5.20 = 1.6923, so RSI = 100 − 100 / 2.6923 = 100 − 37.14 = 62.86 (rounded).

A single up-candle of 1.00 lifts RSI from 60 to about 62.86.

Because the formula is a ratio, RSI cannot leave the 0 to 100 range. If there are no losses at all, RSI is 100. If price is completely flat, the ratio is undefined, and the `RSI` node returns 50 for flat prices and for the first candle.

A shorter period makes RSI swing more widely and reach the extremes more often, while a longer one keeps it closer to 50. The period therefore changes what a threshold such as 70 means, so a threshold found with one period should not be copied to another without testing.

**Common rules of thumb for reading RSI, not trading rules.**

| RSI value | What it describes | Caution |
| --- | --- | --- |
| Above 70 | Recent moves mostly upward | Can persist for many candles in a strong trend |
| Around 50 | Gains and losses about balanced | Says little about direction |
| Below 30 | Recent moves mostly downward | Can persist for many candles in a strong downtrend |

## Overbought and oversold are not signals

A common rule of thumb calls RSI above 70 **overbought** and below 30 **oversold**. These are conventions, not laws. A high RSI only says that recent moves were mostly upward, and in a strong trend RSI can stay high for a long time while price keeps rising.

> **Overbought does not mean about to fall**
>
> Selling only because RSI crossed above 70 treats a description of the past as a prediction. Test any RSI threshold in a backtest, on several markets and periods, and check that it still behaves similarly out of sample.

Because RSI is built from closes alone, it carries no information beyond price. It is often more useful as a filter or a measure of momentum inside a larger rule than as a standalone trigger.

## In the graph editor

The `RSI` node has a single input socket, `Close`, an output socket `RSI` and a `Period (N)` setting. Connect `Data.Close` to it. To express a threshold, send the `RSI` output to a `LessThan` or `GreaterThan` node and compare it with a number constant, for example 30.

> **Plot RSI**: Connect an `RSI` node to a `VisualizeLine` node to draw it in its own pane and compare it with the candles. [Open the graph editor](https://quantraider.com/nodesystem)

## Key takeaways

- RSI = 100 − 100 / (1 + RS), where RS is the average gain divided by the average loss over N candles.
- With Wilder smoothing the averages update as (previous × (N − 1) + new) / N, and QuantRaider's `RSI` node uses Wilder smoothing.
- Readings above 70 or below 30 are rules of thumb, and a strong trend can keep RSI there for a long time.
- RSI is derived from closes only, so it is best treated as a measure of momentum rather than a standalone signal.

> Educational content, not financial advice. Trading involves risk of loss.
