RSI

Calculate the Relative Strength Index (RSI) with built-in divergence and reversal detection. The RSI rule produces a momentum oscillator that ranges from 0 to 100, measuring the speed and magnitude of price changes to identify overbought and oversold conditions. Beyond the core RSI value, this rule automatically detects bullish and bearish divergences as well as positive and negative reversals, giving you comprehensive momentum analysis in a single rule.

How It Works

The RSI rule calculates the Relative Strength Index by comparing the average magnitude of recent gains to the average magnitude of recent losses over a configurable lookback period. The result is normalised to a 0–100 scale where values above the High Level (typically 70) indicate overbought conditions and values below the Low Level (typically 30) indicate oversold conditions.

In addition to the core RSI value, the rule performs divergence and reversal analysis over a separate configurable lookback period:

  • Bullish Divergence — Detected when the price makes a lower low but the RSI makes a higher low. This suggests weakening downward momentum and a potential upward reversal.
  • Bearish Divergence — Detected when the price makes a higher high but the RSI makes a lower high. This suggests weakening upward momentum and a potential downward reversal.
  • Positive Reversal — Detected when the RSI makes a lower low but the price makes a higher low. This is a confirmation signal that the prevailing uptrend may continue.
  • Negative Reversal — Detected when the RSI makes a higher high but the price makes a lower high. This is a confirmation signal that the prevailing downtrend may continue.

The RSI calculation can optionally use a smoothing moving average applied to the gain and loss averages. When a Smoothing MA Type is specified, the internal gain and loss series are smoothed using the selected algorithm before the RSI is computed, which can reduce noise in volatile markets.

Inputs

Input Description Required Default
Source The numeric data series to calculate the RSI from. Typically connected to a close price, but can be any numeric output such as a calculated value or another indicator. Yes
Offset The number of bars to look back into the historical series before returning the value. An offset of 0 returns the current value, 1 returns the previous bar's value, and so on. No 0
MA Length The number of data points (bars) used in the RSI calculation. This determines the lookback period for computing the average gains and average losses. Shorter lengths produce more sensitive, volatile RSI readings; longer lengths produce smoother, more stable readings. No 14
RSI High Level The threshold above which the RSI is considered to be in overbought territory. This level is used internally for divergence and reversal detection logic. No 70
RSI Low Level The threshold below which the RSI is considered to be in oversold territory. This level is used internally for divergence and reversal detection logic. No 30
DR Length The lookback period used for divergence and reversal detection. This controls how many bars are examined when scanning for divergence and reversal patterns between the price and the RSI. No 14
Smoothing MA Type An optional moving average algorithm applied to the internal gain and loss averages before the RSI is calculated. When set, this smooths the RSI computation to reduce noise. Available values: Simple, Exponential, Double Exponential, Running, Weighted, Hull, Arnaud Legoux. No
Shift Controls the offset of the Gaussian weighting curve when the Smoothing MA Type is set to Arnaud Legoux (ALMA). A value of 0 centres the weight on older data, 1 on newer data, and 0.85 is the standard default. No 0.85
Sigma Controls the width of the Gaussian weighting curve when the Smoothing MA Type is set to Arnaud Legoux (ALMA). Higher values create a broader, smoother curve. No 6.0

Outputs

Output Description List
Value The calculated RSI value for the current bar (or the bar specified by the Offset), ranging from 0 to 100. Connect this to comparison rules or condition logic to trigger actions based on overbought or oversold levels. No
Bullish Divergence A boolean signal that is true when a bullish divergence is detected (price makes a lower low while RSI makes a higher low), indicating potential upward momentum shift. No
Bearish Divergence A boolean signal that is true when a bearish divergence is detected (price makes a higher high while RSI makes a lower high), indicating potential downward momentum shift. No
Positive Reversal A boolean signal that is true when a positive reversal is detected (RSI makes a lower low while price makes a higher low), suggesting continuation of an existing uptrend. No
Negative Reversal A boolean signal that is true when a negative reversal is detected (RSI makes a higher high while price makes a lower high), suggesting continuation of an existing downtrend. No

Tips

Use the RSI Value output with a Compare Switch rule to build classic overbought/oversold strategies: trigger a sell signal when RSI crosses above 70 and a buy signal when it crosses below 30. For higher-probability entries, combine the Bullish Divergence output with an oversold RSI condition to confirm that downward momentum is exhausting before entering a long trade. The divergence and reversal outputs work particularly well as filters for trend-following strategies, helping you avoid entering trades against fading momentum. Adjust the DR Length to match your trading timeframe — shorter periods catch more frequent but less reliable divergences, while longer periods produce fewer but stronger signals.

Was this helpful? Let us know