How to Implement RSI Conditions
Problem
You want to use the Relative Strength Index (RSI) to identify overbought/oversold conditions, generate entry/exit signals, or detect divergences in your trading algorithm.
Prerequisites
- Basic understanding of entry conditions
- Familiarity with momentum indicators
Understanding RSI
What is RSI?
The Relative Strength Index (RSI) is a momentum oscillator that measures the speed and magnitude of price changes. It oscillates between 0 and 100.
Formula:
RSI = 100 - (100 / (1 + RS))
RS = Average Gain / Average Loss (over period)
Default Period: 14 candles
RSI Levels
| Level | Interpretation | Action |
|---|---|---|
| 70-100 | Overbought | Consider selling or taking profits |
| 50-70 | Bullish | Upward momentum |
| 30-50 | Bearish | Downward momentum |
| 0-30 | Oversold | Consider buying |
Traditional Levels vs Aggressive Levels
Traditional (Conservative):
- Overbought: 70
- Oversold: 30
- More reliable signals, fewer trades
Aggressive:
- Overbought: 80
- Oversold: 20
- Fewer signals, stronger extremes
Solution
Example 1: Basic Oversold Entry
Enter long when RSI drops below 30 (oversold condition).
{
"entryConditions": {
"positionType": "long",
"logicalOperator": "AND",
"conditions": [
{
"type": "indicator_value",
"indicator": "RSI",
"period": 14,
"comparison": "below",
"value": 30
}
]
}
}
Explanation: This strategy enters long positions when RSI indicates the asset is oversold, expecting a bounce back.
Example 2: Basic Overbought Entry (Short)
Enter short when RSI rises above 70 (overbought condition).
{
"entryConditions": {
"positionType": "short",
"logicalOperator": "AND",
"conditions": [
{
"type": "indicator_value",
"indicator": "RSI",
"period": 14,
"comparison": "above",
"value": 70
}
]
}
}
Explanation: This strategy enters short positions when RSI indicates the asset is overbought, expecting a pullback.
Example 3: RSI Crosses Above Oversold Level
Enter when RSI crosses back above 30 (confirming reversal).
{
"entryConditions": {
"positionType": "long",
"logicalOperator": "AND",
"conditions": [
{
"type": "indicator_value",
"indicator": "RSI",
"period": 14,
"comparison": "crosses_above",
"value": 30
}
]
}
}
Explanation: Instead of entering when RSI is below 30, wait for it to cross back above 30, confirming the reversal has begun.
Example 4: RSI with Trend Filter
Only take RSI oversold signals in an uptrend.
{
"entryConditions": {
"positionType": "long",
"logicalOperator": "AND",
"conditions": [
{
"type": "price_indicator",
"priceType": "close",
"indicator": "EMA",
"period": 200,
"comparison": "above"
},
{
"type": "indicator_value",
"indicator": "RSI",
"period": 14,
"comparison": "below",
"value": 30
}
]
}
}
Explanation: This strategy combines:
- Price above 200 EMA (uptrend confirmation)
- RSI below 30 (oversold)
This filters out oversold signals in downtrends, which often continue lower.
Example 5: RSI Midline Cross (50 Level)
Enter long when RSI crosses above 50 (momentum shift).
{
"entryConditions": {
"positionType": "long",
"logicalOperator": "AND",
"conditions": [
{
"type": "indicator_value",
"indicator": "RSI",
"period": 14,
"comparison": "crosses_above",
"value": 50
}
]
}
}
Explanation: RSI crossing above 50 indicates bullish momentum is taking over. This is a trend-following signal rather than a reversal signal.
Example 6: Extreme RSI Levels (Aggressive)
Use more extreme levels for stronger signals.
{
"entryConditions": {
"positionType": "long",
"logicalOperator": "AND",
"conditions": [
{
"type": "indicator_value",
"indicator": "RSI",
"period": 14,
"comparison": "below",
"value": 20
}
],
"confirmationCandles": 2
}
}
Explanation: Using RSI < 20 instead of < 30 provides stronger oversold signals. Adding 2 confirmation candles ensures the reversal is underway.
Example 7: RSI Range Trading
Buy at oversold, sell at overbought in ranging markets.
{
"entryConditions": {
"positionType": "both",
"logicalOperator": "OR",
"conditions": [
{
"type": "indicator_value",
"indicator": "RSI",
"period": 14,
"comparison": "below",
"value": 30
},
{
"type": "indicator_value",
"indicator": "RSI",
"period": 14,
"comparison": "above",
"value": 70
}
]
},
"exitConditions": {
"exitOnOppositeSignal": true,
"closeImmediately": false
}
}
Explanation: This strategy:
- Enters long when RSI < 30
- Enters short when RSI > 70
- Exits when opposite signal occurs
Perfect for ranging/sideways markets.
Example 8: RSI Divergence Detection (Manual)
While automatic divergence detection isn't built-in, you can manually identify divergences:
Bullish Divergence:
- Price makes lower lows
- RSI makes higher lows
- Signal: Potential upward reversal
Bearish Divergence:
- Price makes higher highs
- RSI makes lower highs
- Signal: Potential downward reversal
{
"entryConditions": {
"positionType": "long",
"logicalOperator": "AND",
"conditions": [
{
"type": "indicator_value",
"indicator": "RSI",
"period": 14,
"comparison": "below",
"value": 40
},
{
"type": "indicator_value",
"indicator": "RSI",
"period": 14,
"comparison": "crosses_above",
"value": 40
}
]
}
}
Explanation: Look for RSI crossing back above 40 after being oversold, which often coincides with bullish divergence patterns.
Example 9: Multiple RSI Periods
Use two RSI periods for confirmation.
{
"entryConditions": {
"positionType": "long",
"logicalOperator": "AND",
"conditions": [
{
"type": "indicator_value",
"indicator": "RSI",
"period": 7,
"comparison": "below",
"value": 30
},
{
"type": "indicator_value",
"indicator": "RSI",
"period": 14,
"comparison": "below",
"value": 30
}
]
}
}
Explanation: Both short-term (7) and standard (14) RSI must be oversold, providing stronger confirmation.
Example 10: RSI Exit Strategy
Use RSI to exit positions at overbought levels.
{
"entryConditions": {
"positionType": "long",
"logicalOperator": "AND",
"conditions": [
{
"type": "price_indicator",
"priceType": "close",
"indicator": "EMA",
"period": 20,
"comparison": "crosses_above"
}
]
},
"exitConditions": {
"customExitConditions": [
{
"type": "indicator_value",
"indicator": "RSI",
"period": 14,
"comparison": "above",
"value": 70
}
]
}
}
Explanation: Enter on EMA crossover, exit when RSI reaches overbought (70), locking in profits before potential reversal.
Verification
After configuring your RSI conditions:
- Backtest the strategy to see historical performance
- Check signal frequency - Are you getting enough signals?
- Verify RSI calculations - Ensure the period is correct
- Test different levels - Try 20/80 vs 30/70
- Paper trade first before risking real capital
Troubleshooting
Problem: Too Many False Signals
Solution:
- Use more extreme levels (20/80 instead of 30/70)
- Add trend filter (only trade with the trend)
- Add confirmation candles
- Combine with other indicators (MACD, moving averages)
Problem: Missing Good Opportunities
Solution:
- Use less extreme levels (30/70 instead of 20/80)
- Remove or reduce confirmation candles
- Consider RSI midline crosses (50 level)
Problem: RSI Stays Overbought/Oversold Too Long
Solution:
- This is normal in strong trends
- Add trend filter to avoid counter-trend trades
- Use RSI crosses instead of absolute levels
- Consider using RSI for exits instead of entries in trending markets
Problem: Divergences Not Working
Solution:
- Divergences work best in ranging markets
- Add volume confirmation
- Wait for RSI to cross back through midline (50)
- Combine with support/resistance levels
Best Practices
-
Adjust levels for market conditions:
- Trending markets: Use 20/80 or ignore overbought/oversold
- Ranging markets: Use 30/70 for more signals
-
Combine with trend indicators:
- Only take oversold signals in uptrends
- Only take overbought signals in downtrends
-
Use different periods:
- 7 RSI: More sensitive, more signals
- 14 RSI: Standard, balanced
- 21 RSI: Less sensitive, fewer signals
-
Watch for divergences:
- Bullish divergence: Price lower low, RSI higher low
- Bearish divergence: Price higher high, RSI lower high
-
RSI in strong trends:
- In strong uptrends, RSI may stay 40-80
- In strong downtrends, RSI may stay 20-60
- Adjust your levels accordingly
-
Exit strategies:
- Exit longs when RSI > 70
- Exit shorts when RSI < 30
- Or use opposite RSI signal