RSI

The RSI measures the speed and change of price movements to identify overbought and oversold conditions.

Role in the strategy

SlotAvailableRole
Entry PointNo—
Entry RuleYesFilters entries: allows or denies opening a position.
Exit PointNo—
Exit RuleYesTriggers exits: allows or denies closing a position.

The RSI produces conditions, not order prices. As an entry rule it is ANDed with the entry point and the other entry rules; as an exit rule it is ORed with the other exit rules. See Indicators for the slot semantics.

Logic rules

The RSI offers the standard oscillator rule set:

RuleLong signal is 1 whenShort signal is 1 when
RSI risesRSI rose on the previous barRSI fell on the previous bar
RSI fallsRSI fell on the previous barRSI rose on the previous bar
RSI is higher than the Level lineRSI is above 30 (Level)RSI is below 70 (100 − Level)
RSI is lower than the Level lineRSI is below 30 (Level)RSI is above 70 (100 − Level)
RSI crosses the Level line upwardRSI crossed above 30 from belowRSI crossed below 70 from above
RSI crosses the Level line downwardRSI crossed below 30 from aboveRSI crossed above 70 from below
RSI changes its direction upwardRSI formed a valley (down then up)RSI formed a peak (up then down)
RSI changes its direction downwardRSI formed a peak (up then down)RSI formed a valley (down then up)

The Level parameter sets the long threshold; the short threshold is always 100 − Level. With the default Level of 30, the long side uses 30 and the short side uses 70.

Parameters

ParameterTypeDefaultRangePurpose
Apply toselectCloseOpen, High, Low, Close, Median, Typical, WeightedPrice series the RSI is calculated from
Periodnumber142 to 1000Number of bars over which gains and losses are averaged
Levelnumber300 to 100Long threshold; the short threshold is 100 − Level

Calculation

The RSI is calculated on the selected price series (tech.RSI in engine/indicator-engine/tech.ts):

  1. For each bar, the change is the difference from the previous bar's price.
  2. Average gain and average loss are smoothed with the Wilder method over the Period.
  3. RSI = 100 − 100 / (1 + RS), where RS = average gain / average loss.

The result is drawn as a line named RSI in its own chart pane below the price chart (separatedChart). The first valid bar is the value's start plus the signal shift plus two warm-up bars.

Backtesting

  • The rule is evaluated on the previous (closed) bar; the signal applies to the current bar.
  • Comparisons use a small dead zone (SIGMA = 0.000001): a difference smaller than that does not count as a rise, a fall, or a crossing.
  • The RSI contributes only long/short signal arrays — it never changes the entry or exit order price. The order price comes from the entry point or exit point indicator.
  • An entry happens only when the entry point allows the direction and every entry rule passes; an exit happens when the exit point is reached and any exit rule passes.