# Relative Strength Index (RSI)

> Momentum oscillator from 0 to 100 that compares the average gains and losses of the close, with automatic divergence lines.

Updated: 2026-10-25T00:01:52.000Z · https://chartrider.com/docs/indicators/rsi/

## What you see
A line in its own pane on a fixed scale from 0 (bottom) to 100 (top). No 70/30 lines are drawn. Green lines in the pane mark bullish divergences, red lines bearish ones; each connects the RSI at two swing points.

## How it is calculated
ChartRider uses Wilder's method on the close, with N = Period:
1. The change of each candle is `close − previous close`. Gains are the positive changes, losses the negative ones taken as positive numbers.
2. The first average gain and average loss are simple averages over the first N changes.
3. After that, Wilder smoothing: `average = (previous average × (N − 1) + current gain or loss) / N`.
4. `RS = average gain / average loss` and `RSI = 100 − 100 / (1 + RS)`. Without losses the RSI is 100, without gains 0.

The first value appears on candle N + 1.

**Divergences.** A swing low is a candle whose close is at or below the closes of the `Period` candles before it and of the following candles set by `Look Back Range`; swing highs work the other way round. The RSI line gets the same test. A bullish divergence is two consecutive swing lows in price where the second is lower, while the RSI has swing lows on the same two candles and the second is higher. A bearish divergence is a higher swing high in price with a lower swing high in the RSI.

## How to read it
- Above 70 is commonly read as overbought, below 30 as oversold. In strong trends the RSI can stay there for a long time.
- Above 50 momentum is on the buyers' side, below 50 on the sellers' side.
- Divergences show fading momentum. A swing is only confirmed after the following candles have closed, so a divergence line appears with that delay.

## Using it in strategies
Output: `value` (0 to 100); the divergence lines are not an output. In the [Trade Setup](https://chartrider.com/docs/strategies/trade-setup/), "Range" keeps entries within a band (e.g. 40 to 60), "Against" suits mean reversion (center 50 with x −20 allows longs at 30 or lower and shorts at 70 or higher), and "Compare" checks a level. In [WickScript](https://chartrider.com/docs/wickscript/) use the built-in `rsi(source, length)`, e.g. `rsi(close, 14)`, or `use indicator "RSI" with period 14 as r` and read `r.value`.

## Settings

Open the settings with the slider icon next to the indicator (Indicators, `F3`). Numeric settings can be swept as Step 1 / Step 2 parameters when you run a strategy.

### Inputs

| Setting | Type | Default | Description |
|---|---|---|---|
| Period | Number | `14` | Number of price changes in Wilder's average (N). Also the number of candles before a swing point that the swing has to beat for divergence detection. (min 1) |
| Look Back Range | Number | `2` | Candles after a swing point that are checked before the swing counts for a divergence. Higher values give fewer, later divergences. (min 1) |
| Height | Number | `70` | Height of the pane in pixels. (min 30) |

### Styles

| Setting | Type | Default | Description |
|---|---|---|---|
| Line Color | Color | `#4444ff` |  |

## Outputs

These values can be used in Trade Setup triggers, filters and exits (see [Trade Setup](https://chartrider.com/docs/strategies/trade-setup/)) and in WickScript.

| Output | In WickScript | Description |
|---|---|---|
| value | `value` |  |

## Use in WickScript

`use indicator` creates this indicator inside a script, with settings by their ID. Each output is a field of the name after `as`. See [WickScript indicators](https://chartrider.com/docs/wickscript/indicators/).

```wickscript
wickscript 1
indicator "Relative Strength Index (RSI) from the list" in pane
use indicator "RSI" with period 14 as myRsi
show myRsi.value as line "value"
```
