# RSI & Wilder's RSI

RSI is a momentum oscillator that compares the magnitude of a stock's recent gains to the magnitude of its recent losses and turns that information into a number that ranges from zero to one hundred. RSI is an overbought-oversold indicator. Stocks with high RSI values can be interpreted as having overbought positions; stocks with low RSI values can be interpreted as having oversold positions.

The Relative Strength Index (RSI) was created by J. Welles Wilder. It was first introduced in Commodities (now Futures) magazine in June, 1978.

RSI is calculated using the following formula:

RSI = 100 - (100 / (1+RS))

RS = n period average of up closes / n period average of down closes

How are RSI and Wilder's RSI different?

In RSI, RS uses a simple average of the up and down closes. In Wilder's RSI, RS uses Wilder's smoothing which is a different form of exponential averaging.

Wilder's smoothing = Previous MA value + (1/n periods * (Close - Previous MA))

Custom PCF Formula
 Function Version Wilder's RSI (with Wilder's smoothing) `WRSI(x, z)` `x`=Period, `y`=SMA, `z`=Offset Plain RSI (without Wilder's smoothing) `RSI(x, y, z)` Indicator Version Wilder's RSI (with Wilder's smoothing) `WRSIx.z` Plain RSI (without Wilder's smoothing) `RSIx.y.z`

Where `x` is the period which must be an integer.

Where `y` is the period of an optional simple moving average applied to the plain RSI which must be an integer. Note that leaving this at 1 is the same as not applying a moving average.

Where `z` is the offset. An offset of 1 returns the value of the previous bar instead of the current bar.

The syntax of these two indicators are not the same with just a W in front of the plain RSI to get the Wilder's RSI. The plain RSI has three parameters including an optional simple moving average parameter. The Wilder's RSI only has two parameters and does not include the simple moving average parameter.

### Examples

A 14 period Wilder's RSI for the current bar can be written as follows.

`WRSI14.0`

But you can leave off the offset parameter because it is for the current bar.

`WRSI14`

You would need to add back the offset parameter if you wanted the value for the previous bar instead.

`WRSI14.1`

A 14 period plain RSI for the current bar can be written as follows.

`RSI14.1.0`

But you can leave off both the SMA parameter and the offset parameter if it is for the current bar with no moving average applied.

`RSI14`

If you wanted the value for the previous bar instead of the current bar, you would need to add back both the SMA parameter and the offset parameter.

`RSI14.1.1`

A two period simple moving average of the current 14 period plain RSI could be written as follows.

`RSI14.2`  