TradeScreening

RSI Indicator

Updated · Sources checked

The RSI indicator measures the balance between smoothed gains and losses in a price series on a scale from zero to 100. The period counts chart bars. Calculate gains and losses separately from close-to-close changes, seed both averages, and update them as new bars arrive. A flat seed leaves the formula undefined.

Key points

What the RSI indicator measures

The relative strength index, or RSI, expresses upward price movement as a share of total upward and downward movement after smoothing both components. Where the calculation is defined, it ranges from 0 to 100.

The TTR package documentation describes the ratio of smoothed gains to smoothed losses and lists 14 as its default number of periods. A period is one input bar. A 14-period reading on a daily chart and a 14-period reading on a five-minute chart describe different series. The scale stays the same, but the underlying close-to-close changes differ.

RSI compares moves within one price series. A reading of 70 describes the balance between that series' smoothed gains and losses. It gives neither a percentage return over the last 14 observations nor a comparison with the performance of another security. A series whose changes are twice as large in both directions can give the same reading because both sides of the calculation double. For the business and earnings information that price indicators leave out, see how to read a company’s financial results.

From closing prices to gains and losses

Compute a signed change by subtracting the previous close from the current close. Use the positive part as the gain and the absolute size of the negative part as the loss.

For a move from $40 to $37, the signed change is negative $3, the gain is zero, and the loss input is positive $3. For a move from $37 to $39, the change and gain are positive $2, and the loss input is zero. A flat close contributes zero to both sides. The formulas use changes in price units. Substituting percentage changes changes the inputs, since each percentage has a different previous close in its denominator.

The University of Illinois report’s RSI specification seeds the two averages using the first n changes, including the zero entries, and then updates each average with Wilder's recurrence. A 14-period calculation needs 15 closing prices to produce 14 changes for the seed. Calculate the initial average gain by dividing the sum of gains by 14 and the initial average loss by dividing the sum of losses by 14. Dividing only by the number of bars that rose or fell changes the calculation.

For each subsequent bar, multiply the previous average by n minus one, add the new gain or loss, and divide the sum by n. The new observation has weight 1/n. The previous average carries information from earlier bars, with diminishing weight at each update. A simple moving average of the latest n changes instead drops one change in full at each step. The guide to simple and exponential averages explains how different weighting rules affect what a chart displays.

Wilder smoothing in a five-close example

Three changes supply the seed for a three-period RSI. The fourth change updates the seeded averages and can yield a different result from averaging the most recent three changes.

Example (fictional) Take five consecutive daily closes of $40, $42, $41, $44 and $42. The first three signed changes are positive $2, negative $1 and positive $3. The gain inputs are $2, $0 and $3, and the loss inputs are $0, $1 and $0. The initial smoothed gain is 5/3 and the initial smoothed loss is 1/3. Relative strength is 5, and 100 minus 100 divided by 6 is 83.33 when rounded to two decimals.

The fifth close adds a negative $2 change. The new average gain is ((5/3) × 2 + 0) ÷ 3 = 10/9. The new average loss is ((1/3) × 2 + 2) ÷ 3 = 8/9. Using the gain-over-total version of the formula documented in Rmfrac, multiply 10/9 divided by the sum of 10/9 and 8/9 by 100. This gives 55.56 rounded. A simple average of the most recent three changes would have a gain total of $3 and a loss total of $3, yielding 50.00. Keep the fractions or full decimal precision until the output step so early rounding does not introduce another difference.

Zero gains, zero losses and flat prices

With a positive average gain and zero average loss, the gain-over-total form gives 100. With zero gains and positive losses it gives 0.

The formula 100 × average gain ÷ (average gain + average loss) is equivalent to 100 minus 100 ÷ (1 + relative strength) where relative strength is defined. The gain-over-total form also handles average loss equal to zero when average gain remains positive. If both averages are zero, its denominator is zero and the calculation has no defined value. Check how a chart or library displays this case. A blank value and a value assigned by a convention mean different things.

An entirely flat seed has zero on both sides. A run of flat bars later in the series works differently. With Wilder smoothing and a period greater than one, a flat update multiplies both prior averages by the same positive factor. Their relative proportions stay the same in exact arithmetic. For example, if both averages are positive before a flat bar, the unchanged RSI does not indicate any new upward or downward price movement. The two averages shrank together.

Why two charts can disagree

Match the interval, price series, starting history and smoothing method before comparing RSI readings. Identical period settings can still hide differences in the input series or the amount of history used to calculate the current value.

One chart might use regular-session daily closes while another builds its series from a different session boundary. A price split can also create a jump in a series that does not adjust historical prices. Note the exact input and whether the latest bar has closed. A reading computed as a live bar changes can differ from a reading calculated once that bar ends. The chart setup checklist covers the input labels, and the synthetic quote and volume calculator gives a separate example of how the observation window changes market statistics.

You may see guide lines at 70 and 30. The calculation itself never uses those lines. They are reference levels for interpreting the displayed value, and repeated gains or losses can keep the series on the same side of a line across multiple bars. A level describes the recent balance of movement with the chosen inputs. By itself it gives no date, direction or size for the next move.

When reconciling a spreadsheet with a chart, find the earliest bar where the two readings disagree. If they differ at the seed, compare the starting closes and the first gain and loss totals. If the seeds match, check the next change and the weight each calculation assigns it.

Frequently asked questions

How is the RSI indicator calculated?

Split close-to-close gains and losses into two nonnegative series and smooth each one. Divide the smoothed gain by the sum of the smoothed gain and loss, then multiply by 100 if the sum is positive.

Does a 14-period RSI always use days?

The period counts chart bars. A daily series uses days with bars, while a five-minute series counts five-minute bars.

Why did my RSI differ from a chart with the same period?

A chart may use a different session, price adjustment, smoothing convention or starting history. Compare the inputs and wait for both charts to use the same completed bar if one uses a live bar.

What happens to RSI when there are no losses?

An average loss of zero with a positive average gain yields 100 in the gain-over-total form. If both averages are zero, the formula is undefined and the display depends on the implementation.

Related guides

Sources

What changed