# Technical Studies Reference

### Stochastic RSI

This staudy calculates and displays the Stochastic RSI for Close (Last) Price data. The RSI is used in the calculation.

Let $$C$$ be a random variable denoting the Close Price, and let $$C_t$$ be the value of the Close Price at Index $$t$$. Then the RSI of $$C$$ with RSI Length $$n_{RSI}$$ at Index $$t$$ is denoted as $$RSI_t(C,n_{RSI})$$, and it is calculated in terms of a Simple Moving Average for $$t \geq n_{RSI} - 1$$.

Note: Depending on the setting of the Input Average Type, the Simple Moving Averages in the calculations of $$RS_t\left(X,n_{RSI}\right)$$ and $$\overline{RSI}_t(RSI(X,n_{RSI}),n)$$ could be replaced with Exponential Moving Averages, Linear Regression Moving Averages, Weighted Moving Averages, Wilders Moving Averages, Simple Moving Averages - Skip Zeros, or Smoothed Moving Averages. The types of all three Moving Averages in the calculation are determined by this one Input.

Let the RSI HighestLowest Length Input be denoted as $$n_{HL}$$. We denote the maximum and minimum values of $$RSI_t(C,n)$$ over a sliding window of Length $$n_{HL}$$ at Index $$t$$ as $$MaxRSI_t\left(C,n,n_{HL}\right)$$ and $$MinRSI_t\left(C,n,n_{HL}\right)$$, respectively. We compute them for $$t \geq n_{RSI} + n_{HL} - 1$$ as follows.

$$MaxRSI_t\left(C,n,n_{HL}\right) = \max\{RSI_{t - n_{HL} + 1}(C,n), RSI_{t - n_{HL} + 2}(C,n), ... , RSI_t(C,n)\}$$

$$MinRSI_t\left(C,n,n_{HL}\right) = \min\{RSI_{t - n_{HL} + 1}(C,n), RSI_{t - n_{HL} + 2}(C,n), ... , RSI_t(C,n)\}$$

We denote the Stochastic RSI for the given Inputs at Index $$t$$ as $$StochRSI_t\left(C,n,n_{HL}\right)$$, and we compute it for $$t \geq n_{RSI} + n_{HL} - 1$$ with the following recursion relation.

$$\displaystyle{StochRSI_t\left(C,n,n_{HL}\right) = \left\{ \begin{matrix} \frac{RSI_t(C,n) - MinRSI_t\left(C,n,n_{HL}\right)}{MaxRSI_t\left(C,n,n_{HL}\right) - MinRSI_t\left(C,n,n_{HL}\right)} & MaxRSI_t\left(C,n,n_{HL}\right) - MinRSI_t\left(C,n,n_{HL}\right) \neq 0 \\ StochRSI_{t - 1}\left(C,n,n_{HL}\right) & MaxRSI_t\left(C,n,n_{HL}\right) - MinRSI_t\left(C,n,n_{HL}\right) = 0 \end{matrix}\right .}$$