# Stochastic RSI (STOCH RSI)

Stochastic RSI, also called StochRSI, as an oscillator which uses a Stochastic formula on a set of RSI values to measure momentum and determine if an asset is overbought or oversold. RSI is, essentially, an indicator of an indicator and is used as it is more sensitive, and consequently able to detect more signals, than the original Stochastic indicator.

### **Trading application**

Within a range of 0 to 100, this indicator shows two lines, %K (*K* in the calculation formula belove) and %D (*D* in the calculation formula belove). Overbought conditions are indicated by the %K line crossing above 80, while oversold conditions are present once %K goes down below 20. When the 2 lines intersect, we can interpret that there might be a reversal in the trend: %K crossing above %D indicates bullish conditions, while %K crossing below %D indicates bearish conditions.&#x20;

Divergences also reflect bullish or bearish conditions: we can consider the environment bearish if the asset’s price increases more than the %D (e.g. reaching a new high while the indicator doesn’t), in the same way, it would be bullish to see the asset’s price decreasing more than the %D does.

### **Calculation**

$$
K = (RSI - RSIL) / (RSIH - RSIL)
$$

$$
D=100\*((K1+K2+K3)/3)
$$

*RSI: Current RSI*\
*RSIL: Lowest RSI value in last n periods*\
*RSIH: Highest RSI value in last n periods*\
*K1, K2 and K3: Last 3 values of K*

### **Parameters**

#### Input Parameters

| Name     | Type | Range of value    | Description                          |
| -------- | ---- | ----------------- | ------------------------------------ |
| `period` | int  | <1, int.MaxValue> | Number of bars used for calculation. |

#### Output Parameters

Indicator ouptuts a single value.

| Type   | Range of value       |
| ------ | -------------------- |
| double | (0, double.MaxValue) |

### Examples

```csharp
// Prints the current value of a 20 period Stochastic RSI using
// the daily bars close price value.
stochRsi = indicators.StochasticRSI(20).OnSeries(dailyBars.Close);
Log(stochRsi.Value.ToString());

// Evaluates if the current bar Stochastic RSI value is greater than
// the value one bar ago.
stochRsi = indicators.StochasticRSI(20).Keep(2).OnSeries(dailyBars.Close);
if (stochRsi.Values[0] > stochRsi.Values[1]) {
    Log("Stochatic RSI is rising.");
}
```

#### Complete example

```csharp
using Signals.DataSeries.Bars;
using Signals.Framework;
using Signals.Indicators.StochasticRSI;

public class MyStrategy : SingleMarketStrategy
{
    private Bars dailyBars;
    private StochasticRSI stochRsi;

    public override void Setup(DataMarketplace data, IndicatorsMarketplace indicators)
    {
        dailyBars = data.Bars(BarPeriodType.Day, 1).WithOffset(25);
        stochRsi = indicators.StochasticRSI(20).Keep(2).OnSeries(dailyBars.Close);
    }

    public override void RegisterActions()
    {
        OnUpdateOf(dailyBars).Do(() =>
        {
            Log(stochRsi.Value.ToString());

            if (stochRsi.Values[0] > stochRsi.Values[1]) {
                Log("Stochatic RSI is rising.");
            } else {
                Log("Stochatic RSI is descending.");
            }
        });
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.signals.network/knowledge-base/indicators/oscilators/stochastic-rsi-stoch-rsi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
