RSI compares the average gain on up bars to the average loss on down
bars over a period window and maps the result to 0-100. It's the
most widely used oscillator in retail TA.
Formula
avg_gain = EMA(positive bar deltas, period)
avg_loss = EMA(absolute negative bar deltas, period)
rs = avg_gain / avg_loss
rsi = 100 - 100 / (1 + rs)Params
period- number of bars in the gain/loss window. Default 14.
Output
Single column named after your indicator (e.g. rsi).
Common thresholds
| Range | Classical meaning |
|---|---|
| > 70 | Overbought |
| < 30 | Oversold |
| 50 | Trend pivot |
These thresholds are guidelines, not laws. In strong uptrends RSI sits above 50 for long stretches and overbought readings are continuation signals, not reversals. Calibrate against backtest data for your symbol + timeframe.
Usage
- Mean reversion:
rsi < 30for long,rsi > 70for short. Pair with a trend filter so you only fade pullbacks, not reversals. - Trend confirmation: require
rsi > 50for longs andrsi < 50for shorts. - Divergence: same idea as with MACD. Not auto-detected by the engine.
Pitfalls
- Strong trends keep RSI extreme. A "fade overbought" rule can bleed through an entire bull run.
- Lower timeframes are noisier. RSI(14) on 1m flips constantly; consider a longer period for scalp setups.
