RSI
The RSI measures the speed and change of price movements to identify overbought and oversold conditions.
Role in the strategy
| Slot | Available | Role |
|---|---|---|
| Entry Point | No | — |
| Entry Rule | Yes | Filters entries: allows or denies opening a position. |
| Exit Point | No | — |
| Exit Rule | Yes | Triggers 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:
| Rule | Long signal is 1 when | Short signal is 1 when |
|---|---|---|
| RSI rises | RSI rose on the previous bar | RSI fell on the previous bar |
| RSI falls | RSI fell on the previous bar | RSI rose on the previous bar |
| RSI is higher than the Level line | RSI is above 30 (Level) | RSI is below 70 (100 − Level) |
| RSI is lower than the Level line | RSI is below 30 (Level) | RSI is above 70 (100 − Level) |
| RSI crosses the Level line upward | RSI crossed above 30 from below | RSI crossed below 70 from above |
| RSI crosses the Level line downward | RSI crossed below 30 from above | RSI crossed above 70 from below |
| RSI changes its direction upward | RSI formed a valley (down then up) | RSI formed a peak (up then down) |
| RSI changes its direction downward | RSI 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
| Parameter | Type | Default | Range | Purpose |
|---|---|---|---|---|
| Apply to | select | Close | Open, High, Low, Close, Median, Typical, Weighted | Price series the RSI is calculated from |
| Period | number | 14 | 2 to 1000 | Number of bars over which gains and losses are averaged |
| Level | number | 30 | 0 to 100 | Long 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):
- For each bar, the change is the difference from the previous bar's price.
- Average gain and average loss are smoothed with the Wilder method over the Period.
RSI = 100 − 100 / (1 + RS), whereRS = 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.
Related
- Indicators index
- Stochastic — same 0-100 level logic
- Strategy Editor