RSI Trading Bot Development
RSI (Relative Strength Index) is an overbought/oversold oscillator developed by Welles Wilder in 1978. Still one of the most used indicators. An RSI-based bot is simple to implement but requires careful tuning: in trending conditions RSI gives many false signals.
How RSI Works
RSI measures the speed and change of price movements. Formula:
RSI = 100 - (100 / (1 + RS))
RS = Average Gain / Average Loss (over N periods, standard: 14)
Values: 0–100. Traditional levels:
- Above 70 — overbought (signal to sell in counter-trend strategy)
- Below 30 — oversold (signal to buy)
Bot Implementation
import ccxt
import pandas_ta as ta
import asyncio
class RSIBot:
def __init__(self, symbol: str, rsi_period: int = 14,
oversold: float = 30, overbought: float = 70):
self.exchange = ccxt.binance({'apiKey': API_KEY, 'secret': SECRET})
self.symbol = symbol
self.rsi_period = rsi_period
self.oversold = oversold
self.overbought = overbought
async def get_signal(self) -> str:
ohlcv = await self.exchange.fetch_ohlcv(self.symbol, '1h', limit=100)
df = pd.DataFrame(ohlcv, columns=['ts', 'open', 'high', 'low', 'close', 'vol'])
df['rsi'] = ta.rsi(df['close'], length=self.rsi_period)
current_rsi = df['rsi'].iloc[-1]
if current_rsi < self.oversold:
return 'BUY'
elif current_rsi > self.overbought:
return 'SELL'
return 'HOLD'
Market Condition Tuning
Standard 30/70 levels work in sideways markets. On strong trends RSI can stay above 70 for hours — bot will sell against the trend and lose. Solutions:
- Raise thresholds on bull market: 40/80 instead of 30/70
- Trend filter: trade RSI only if 200 EMA confirms direction
- RSI divergence: price makes new high, RSI doesn't. This is more reliable reversal signal than just level 70
Development timeline: 1–2 weeks including backtesting on historical data and parameter tuning.







